home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Corel 10 Texture (image/corel10Texture)
| ext
| Unsupported |
1%
| dexvert
| Croteam texture file (image/croteamTextureFile)
| ext
| Unsupported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text
| default
| |
100%
| TrID
| LaTeX 2e document (with rem)
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
| |
100%
| xdgMime
| text/x-matlab
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 25 20 46 69 6c 65 6e 61 | 6d 65 3a 20 4c 61 6d 62 |% Filena|me: Lamb|
|00000010| 64 61 2e 74 65 78 0a 25 | 20 41 75 74 68 6f 72 3a |da.tex.%| Author:|
|00000020| 20 41 6c 61 6e 20 4a 65 | 66 66 72 65 79 0a 25 20 | Alan Je|ffrey.% |
|00000030| 4c 61 73 74 20 6d 6f 64 | 69 66 69 65 64 3a 20 31 |Last mod|ified: 1|
|00000040| 31 20 4d 61 79 20 31 39 | 39 30 0a 25 0a 25 20 43 |1 May 19|90.%.% C|
|00000050| 6f 70 79 72 69 67 68 74 | 20 28 63 29 20 31 39 39 |opyright| (c) 199|
|00000060| 30 20 41 6c 61 6e 20 4a | 65 66 66 72 65 79 2e 20 |0 Alan J|effrey. |
|00000070| 20 50 65 72 6d 69 73 73 | 69 6f 6e 20 69 73 20 67 | Permiss|ion is g|
|00000080| 72 61 6e 74 65 64 20 74 | 6f 20 54 75 67 62 6f 61 |ranted t|o Tugboa|
|00000090| 74 0a 25 20 74 6f 20 70 | 75 62 6c 69 73 68 20 61 |t.% to p|ublish a|
|000000a0| 6e 79 20 6f 72 20 61 6c | 6c 20 6f 66 20 74 68 69 |ny or al|l of thi|
|000000b0| 73 2e 0a 25 0a 25 20 41 | 20 6b 65 79 62 6f 61 72 |s..%.% A| keyboar|
|000000c0| 64 20 63 68 65 63 6b 3a | 0a 25 0a 25 20 20 20 20 |d check:|.%.% |
|000000d0| 20 40 20 23 20 24 20 25 | 20 5e 20 26 20 2a 20 7e | @ # $ %| ^ & * ~|
|000000e0| 20 20 20 61 74 20 68 61 | 73 68 20 64 6f 6c 6c 61 | at ha|sh dolla|
|000000f0| 72 20 70 65 72 63 65 6e | 74 20 63 61 72 65 74 20 |r percen|t caret |
|00000100| 61 6d 70 65 72 73 61 6e | 64 20 61 73 74 65 72 69 |ampersan|d asteri|
|00000110| 73 6b 20 74 69 6c 64 65 | 0a 25 20 20 20 20 20 3a |sk tilde|.% :|
|00000120| 20 3b 20 2c 20 2e 20 20 | 20 20 20 20 20 20 20 20 | ; , . | |
|00000130| 20 63 6f 6c 6f 6e 20 73 | 65 6d 69 63 6f 6c 6f 6e | colon s|emicolon|
|00000140| 20 63 6f 6d 6d 61 20 70 | 65 72 69 6f 64 20 0a 25 | comma p|eriod .%|
|00000150| 20 20 20 20 20 3f 20 21 | 20 20 20 20 20 20 20 20 | ? !| |
|00000160| 20 20 20 20 20 20 20 71 | 75 65 73 74 69 6f 6e 2d | q|uestion-|
|00000170| 6d 61 72 6b 20 65 78 63 | 6c 61 6d 61 74 69 6f 6e |mark exc|lamation|
|00000180| 2d 6d 61 72 6b 0a 25 20 | 20 20 20 20 22 20 27 20 |-mark.% | " ' |
|00000190| 60 20 20 20 20 20 20 20 | 20 20 20 20 20 20 64 6f |` | do|
|000001a0| 75 62 6c 65 2d 71 75 6f | 74 65 20 61 70 6f 73 74 |uble-quo|te apost|
|000001b0| 72 6f 70 68 65 20 62 61 | 63 6b 2d 71 75 6f 74 65 |rophe ba|ck-quote|
|000001c0| 0a 25 20 20 20 20 20 28 | 20 29 20 7b 20 7d 20 5b |.% (| ) { } [|
|000001d0| 20 5d 20 20 20 20 20 20 | 20 70 61 72 65 6e 74 68 | ] | parenth|
|000001e0| 65 73 65 73 20 62 72 61 | 63 65 73 20 73 71 75 61 |eses bra|ces squa|
|000001f0| 72 65 2d 62 72 61 63 6b | 65 74 73 20 0a 25 20 20 |re-brack|ets .% |
|00000200| 20 20 20 2d 20 2b 20 3d | 20 2f 20 5c 20 20 20 20 | - + =| / \ |
|00000210| 20 20 20 20 20 6d 69 6e | 75 73 20 70 6c 75 73 20 | min|us plus |
|00000220| 65 71 75 61 6c 73 20 66 | 6f 72 77 61 72 64 2d 73 |equals f|orward-s|
|00000230| 6c 61 73 68 20 62 61 63 | 6b 73 6c 61 73 68 0a 25 |lash bac|kslash.%|
|00000240| 20 20 20 20 20 5f 20 7c | 20 3c 20 3e 20 20 20 20 | _ || < > |
|00000250| 20 20 20 20 20 20 20 75 | 6e 64 65 72 73 63 6f 72 | u|nderscor|
|00000260| 65 20 76 65 72 74 69 63 | 61 6c 2d 62 61 72 20 6c |e vertic|al-bar l|
|00000270| 65 73 73 2d 74 68 61 6e | 20 67 72 65 61 74 65 72 |ess-than| greater|
|00000280| 2d 74 68 61 6e 0a 25 0a | 0a 5c 64 6f 63 75 6d 65 |-than.%.|.\docume|
|00000290| 6e 74 73 74 79 6c 65 5b | 6c 74 75 67 62 6f 61 74 |ntstyle[|ltugboat|
|000002a0| 2c 4c 61 6d 62 64 61 5d | 7b 61 72 74 69 63 6c 65 |,Lambda]|{article|
|000002b0| 7d 0a 0a 25 20 54 68 69 | 73 20 64 6f 63 75 6d 65 |}..% Thi|s docume|
|000002c0| 6e 74 20 64 65 66 69 6e | 65 73 20 61 20 77 68 6f |nt defin|es a who|
|000002d0| 6c 65 20 6c 6f 61 64 20 | 6f 66 20 65 78 74 72 61 |le load |of extra|
|000002e0| 20 63 6f 6d 6d 61 6e 64 | 73 2c 20 73 6f 6d 65 20 | command|s, some |
|000002f0| 6f 66 20 77 68 69 63 68 | 0a 25 20 6f 76 65 72 2d |of which|.% over-|
|00000300| 72 69 64 65 20 68 6f 77 | 20 4c 61 54 65 58 20 6e |ride how| LaTeX n|
|00000310| 6f 72 6d 61 6c 6c 79 20 | 6c 61 79 73 20 74 68 69 |ormally |lays thi|
|00000320| 6e 67 73 20 6f 75 74 2e | 20 20 46 6f 72 20 65 78 |ngs out.| For ex|
|00000330| 61 6d 70 6c 65 2c 20 7e | 20 69 73 0a 25 20 72 65 |ample, ~| is.% re|
|00000340| 64 65 66 69 6e 65 64 20 | 74 6f 20 67 69 76 65 20 |defined |to give |
|00000350| 61 20 68 61 69 72 73 70 | 61 63 65 20 69 6e 20 6d |a hairsp|ace in m|
|00000360| 61 74 68 20 6d 6f 64 65 | 2e 20 20 54 68 69 73 20 |ath mode|. This |
|00000370| 77 68 6f 6c 65 20 64 6f | 63 75 6d 65 6e 74 0a 25 |whole do|cument.%|
|00000380| 20 73 68 6f 75 6c 64 20 | 70 72 6f 62 61 62 6c 79 | should |probably|
|00000390| 20 62 65 20 70 75 74 20 | 69 6e 20 61 20 67 72 6f | be put |in a gro|
|000003a0| 75 70 20 74 6f 20 73 74 | 6f 70 20 69 74 20 67 65 |up to st|op it ge|
|000003b0| 74 74 69 6e 67 20 69 6e | 20 74 68 65 20 77 61 79 |tting in| the way|
|000003c0| 20 0a 25 20 6f 66 20 6f | 74 68 65 72 20 61 72 74 | .% of o|ther art|
|000003d0| 69 63 6c 65 73 27 20 6d | 61 63 72 6f 73 2e 0a 0a |icles' m|acros...|
|000003e0| 5c 74 69 74 6c 65 7b 4c | 69 73 74 73 20 69 6e 20 |\title{L|ists in |
|000003f0| 5c 54 65 58 27 73 20 4d | 6f 75 74 68 7d 0a 0a 5c |\TeX's M|outh}..\|
|00000400| 61 75 74 68 6f 72 7b 41 | 6c 61 6e 20 4a 65 66 66 |author{A|lan Jeff|
|00000410| 72 65 79 7d 0a 0a 5c 61 | 64 64 72 65 73 73 7b 50 |rey}..\a|ddress{P|
|00000420| 72 6f 67 72 61 6d 6d 69 | 6e 67 20 52 65 73 65 61 |rogrammi|ng Resea|
|00000430| 72 63 68 20 47 72 6f 75 | 70 5c 5c 0a 20 20 20 20 |rch Grou|p\\. |
|00000440| 20 20 20 20 20 4f 78 66 | 6f 72 64 20 55 6e 69 76 | Oxf|ord Univ|
|00000450| 65 72 73 69 74 79 5c 5c | 0a 20 20 20 20 20 20 20 |ersity\\|. |
|00000460| 20 20 31 31 20 4b 65 62 | 6c 65 20 52 6f 61 64 5c | 11 Keb|le Road\|
|00000470| 5c 0a 20 20 20 20 20 20 | 20 20 20 4f 78 66 6f 72 |\. | Oxfor|
|00000480| 64 20 4f 58 31 20 33 51 | 44 7d 0a 0a 5c 6e 65 74 |d OX1 3Q|D}..\net|
|00000490| 61 64 64 72 65 73 73 7b | 41 6c 61 6e 2e 4a 65 66 |address{|Alan.Jef|
|000004a0| 66 72 65 79 40 75 6b 2e | 61 63 2e 6f 78 66 6f 72 |frey@uk.|ac.oxfor|
|000004b0| 64 2e 70 72 67 7d 0a 0a | 5c 6d 61 6b 65 61 74 6c |d.prg}..|\makeatl|
|000004c0| 65 74 74 65 72 0a 0a 25 | 20 54 68 65 20 6d 61 74 |etter..%| The mat|
|000004d0| 68 63 6f 64 65 73 20 66 | 6f 72 20 74 68 65 20 6c |hcodes f|or the l|
|000004e0| 65 74 74 65 72 73 20 41 | 2c 20 2e 2e 2e 2c 20 5a |etters A|, ..., Z|
|000004f0| 2c 20 61 2c 20 2e 2e 2e | 2c 20 7a 20 61 72 65 20 |, a, ...|, z are |
|00000500| 63 68 61 6e 67 65 64 20 | 74 6f 0a 25 20 67 65 6e |changed |to.% gen|
|00000510| 65 72 61 74 65 20 74 65 | 78 74 20 69 74 61 6c 69 |erate te|xt itali|
|00000520| 63 20 72 61 74 68 65 72 | 20 74 68 61 6e 20 6d 61 |c rather| than ma|
|00000530| 74 68 20 69 74 61 6c 69 | 63 20 62 79 20 64 65 66 |th itali|c by def|
|00000540| 61 75 6c 74 2e 20 54 68 | 69 73 20 6d 61 6b 65 73 |ault. Th|is makes|
|00000550| 0a 25 20 6d 75 6c 74 69 | 2d 6c 65 74 74 65 72 20 |.% multi|-letter |
|00000560| 6e 61 6d 65 73 20 6c 6f | 6f 6b 20 6e 65 61 74 65 |names lo|ok neate|
|00000570| 72 2e 20 54 68 65 20 6d | 61 74 68 63 6f 64 65 20 |r. The m|athcode |
|00000580| 66 6f 72 20 63 68 61 72 | 61 63 74 65 72 20 27 63 |for char|acter 'c|
|00000590| 27 0a 25 20 69 73 20 73 | 65 74 20 74 6f 20 22 37 |'.% is s|et to "7|
|000005a0| 30 30 30 20 28 76 61 72 | 69 61 62 6c 65 20 66 61 |000 (var|iable fa|
|000005b0| 6d 69 6c 79 29 20 2b 20 | 22 34 30 30 20 28 74 65 |mily) + |"400 (te|
|000005c0| 78 74 20 69 74 61 6c 69 | 63 29 20 2b 20 63 2e 0a |xt itali|c) + c..|
|000005d0| 25 20 0a 25 20 54 68 69 | 73 20 6e 65 61 74 20 62 |% .% Thi|s neat b|
|000005e0| 69 74 20 6f 66 20 63 6f | 64 65 20 69 73 20 64 75 |it of co|de is du|
|000005f0| 65 20 74 6f 20 4d 69 6b | 65 20 53 70 69 76 65 79 |e to Mik|e Spivey|
|00000600| 2e 0a 0a 5c 64 65 66 5c | 40 73 65 74 6d 63 6f 64 |...\def\|@setmcod|
|00000610| 65 73 23 31 23 32 23 33 | 7b 7b 5c 63 6f 75 6e 74 |es#1#2#3|{{\count|
|00000620| 30 3d 23 31 20 5c 63 6f | 75 6e 74 31 3d 23 33 0a |0=#1 \co|unt1=#3.|
|00000630| 20 20 20 20 20 20 20 20 | 5c 6c 6f 6f 70 20 5c 67 | |\loop \g|
|00000640| 6c 6f 62 61 6c 5c 6d 61 | 74 68 63 6f 64 65 5c 63 |lobal\ma|thcode\c|
|00000650| 6f 75 6e 74 30 3d 5c 63 | 6f 75 6e 74 31 20 5c 69 |ount0=\c|ount1 \i|
|00000660| 66 6e 75 6d 20 5c 63 6f | 75 6e 74 30 3c 23 32 0a |fnum \co|unt0<#2.|
|00000670| 20 20 20 20 20 20 20 20 | 5c 61 64 76 61 6e 63 65 | |\advance|
|00000680| 5c 63 6f 75 6e 74 30 20 | 62 79 31 20 5c 61 64 76 |\count0 |by1 \adv|
|00000690| 61 6e 63 65 5c 63 6f 75 | 6e 74 31 20 62 79 31 20 |ance\cou|nt1 by1 |
|000006a0| 5c 72 65 70 65 61 74 7d | 7d 0a 0a 5c 40 73 65 74 |\repeat}|}..\@set|
|000006b0| 6d 63 6f 64 65 73 7b 60 | 41 7d 7b 60 5a 7d 7b 22 |mcodes{`|A}{`Z}{"|
|000006c0| 37 34 34 31 7d 0a 5c 40 | 73 65 74 6d 63 6f 64 65 |7441}.\@|setmcode|
|000006d0| 73 7b 60 61 7d 7b 60 7a | 7d 7b 22 37 34 36 31 7d |s{`a}{`z|}{"7461}|
|000006e0| 0a 0a 5c 64 65 66 5c 4e | 75 6d 62 65 72 23 31 7b |..\def\N|umber#1{|
|000006f0| 5c 63 73 6e 61 6d 65 20 | 4e 75 6d 62 65 72 2d 23 |\csname |Number-#|
|00000700| 31 5c 65 6e 64 63 73 6e | 61 6d 65 7d 0a 5c 64 65 |1\endcsn|ame}.\de|
|00000710| 66 5c 4c 61 62 65 6c 23 | 31 7b 5c 63 73 6e 61 6d |f\Label#|1{\csnam|
|00000720| 65 20 4c 61 62 65 6c 2d | 23 31 5c 65 6e 64 63 73 |e Label-|#1\endcs|
|00000730| 6e 61 6d 65 7d 0a 0a 5c | 6e 65 77 63 6f 75 6e 74 |name}..\|newcount|
|00000740| 5c 4c 61 73 74 6e 75 6d | 0a 0a 5c 64 65 66 5c 46 |\Lastnum|..\def\F|
|00000750| 6f 72 77 61 72 64 23 31 | 25 0a 20 20 20 7b 5c 67 |orward#1|%. {\g|
|00000760| 6c 6f 62 61 6c 5c 61 64 | 76 61 6e 63 65 5c 4c 61 |lobal\ad|vance\La|
|00000770| 73 74 6e 75 6d 20 62 79 | 20 31 0a 20 20 20 20 5c |stnum by| 1. \|
|00000780| 63 73 6e 61 6d 65 61 66 | 74 65 72 5c 78 64 65 66 |csnameaf|ter\xdef|
|00000790| 7b 4e 75 6d 62 65 72 2d | 23 31 7d 25 0a 20 20 20 |{Number-|#1}%. |
|000007a0| 20 20 20 20 7b 5c 74 68 | 65 5c 4c 61 73 74 6e 75 | {\th|e\Lastnu|
|000007b0| 6d 7d 25 0a 20 20 20 20 | 5c 63 73 6e 61 6d 65 61 |m}%. |\csnamea|
|000007c0| 66 74 65 72 5c 78 64 65 | 66 7b 4c 61 62 65 6c 2d |fter\xde|f{Label-|
|000007d0| 5c 74 68 65 5c 4c 61 73 | 74 6e 75 6d 7d 25 0a 20 |\the\Las|tnum}%. |
|000007e0| 20 20 20 20 20 20 7b 5c | 40 63 75 72 72 65 6e 74 | {\|@current|
|000007f0| 6c 61 62 65 6c 7d 7d 0a | 0a 5c 64 65 66 5c 63 73 |label}}.|.\def\cs|
|00000800| 6e 61 6d 65 61 66 74 65 | 72 23 31 23 32 25 0a 20 |nameafte|r#1#2%. |
|00000810| 20 20 7b 5c 65 78 70 61 | 6e 64 61 66 74 65 72 23 | {\expa|ndafter#|
|00000820| 31 5c 63 73 6e 61 6d 65 | 23 32 5c 65 6e 64 63 73 |1\csname|#2\endcs|
|00000830| 6e 61 6d 65 7d 0a 0a 5c | 64 65 66 5c 42 79 6c 69 |name}..\|def\Byli|
|00000840| 73 74 23 31 25 0a 20 20 | 20 7b 5c 4d 61 70 5c 4c |st#1%. | {\Map\L|
|00000850| 61 62 65 6c 0a 20 20 20 | 20 20 20 7b 5c 49 6e 73 |abel. | {\Ins|
|00000860| 65 72 74 73 6f 72 74 5c | 4c 65 73 73 74 68 61 6e |ertsort\|Lessthan|
|00000870| 0a 20 20 20 20 20 20 20 | 20 20 7b 5c 4d 61 70 5c |. | {\Map\|
|00000880| 4e 75 6d 62 65 72 7b 23 | 31 7d 7d 7d 7d 0a 0a 5c |Number{#|1}}}}..\|
|00000890| 64 65 66 5c 42 79 7b 5c | 53 68 6f 77 5c 42 79 6c |def\By{\|Show\Byl|
|000008a0| 69 73 74 7d 0a 0a 5c 6c | 65 74 5c 62 69 6e 64 73 |ist}..\l|et\binds|
|000008b0| 70 61 63 65 3d 7e 0a 5c | 64 65 66 7e 7b 5c 69 66 |pace=~.\|def~{\if|
|000008c0| 6d 6d 6f 64 65 20 5c 2c | 20 5c 65 6c 73 65 20 5c |mmode \,| \else \|
|000008d0| 62 69 6e 64 73 70 61 63 | 65 20 5c 66 69 7d 0a 0a |bindspac|e \fi}..|
|000008e0| 5c 64 65 66 5c 73 74 61 | 72 74 23 31 7b 5c 6c 65 |\def\sta|rt#1{\le|
|000008f0| 66 74 65 71 6e 7b 23 31 | 7d 5c 71 75 61 64 5c 5c |fteqn{#1|}\quad\\|
|00000900| 7d 0a 0a 5c 64 65 66 5c | 6e 69 6c 7b 5b 5c 2c 5c |}..\def\|nil{[\,\|
|00000910| 2c 5d 7d 0a 0a 5c 6e 65 | 77 74 68 65 6f 72 65 6d |,]}..\ne|wtheorem|
|00000920| 7b 66 61 63 74 7d 7b 46 | 61 63 74 7d 0a 5c 64 65 |{fact}{F|act}.\de|
|00000930| 66 5c 74 68 65 66 61 63 | 74 7b 5c 40 72 6f 6d 61 |f\thefac|t{\@roma|
|00000940| 6e 5c 63 40 66 61 63 74 | 7d 0a 0a 5c 64 65 66 5c |n\c@fact|}..\def\|
|00000950| 63 73 74 6f 6b 23 31 7b | 5c 6c 65 61 76 65 76 6d |cstok#1{|\leavevm|
|00000960| 6f 64 65 5c 74 68 69 6e | 73 70 61 63 65 5c 68 62 |ode\thin|space\hb|
|00000970| 6f 78 7b 5c 76 72 75 6c | 65 5c 76 74 6f 70 7b 5c |ox{\vrul|e\vtop{\|
|00000980| 76 62 6f 78 7b 5c 68 72 | 75 6c 65 5c 6b 65 72 6e |vbox{\hr|ule\kern|
|00000990| 31 70 74 0a 20 20 20 20 | 20 20 20 20 5c 68 62 6f |1pt. | \hbo|
|000009a0| 78 7b 5c 76 70 68 61 6e | 74 6f 6d 7b 5c 74 74 2f |x{\vphan|tom{\tt/|
|000009b0| 7d 5c 74 68 69 6e 73 70 | 61 63 65 7b 5c 74 74 23 |}\thinsp|ace{\tt#|
|000009c0| 31 7d 5c 74 68 69 6e 73 | 70 61 63 65 7d 7d 25 0a |1}\thins|pace}}%.|
|000009d0| 20 20 20 20 20 20 5c 6b | 65 72 6e 31 70 74 5c 68 | \k|ern1pt\h|
|000009e0| 72 75 6c 65 7d 5c 76 72 | 75 6c 65 7d 5c 74 68 69 |rule}\vr|ule}\thi|
|000009f0| 6e 73 70 61 63 65 7d 0a | 0a 5c 62 65 67 69 6e 67 |nspace}.|.\beging|
|00000a00| 72 6f 75 70 20 5c 63 61 | 74 63 6f 64 65 20 60 7c |roup \ca|tcode `||
|00000a10| 3d 30 20 5c 63 61 74 63 | 6f 64 65 20 60 5b 3d 20 |=0 \catc|ode `[= |
|00000a20| 31 0a 5c 63 61 74 63 6f | 64 65 60 5d 3d 32 20 5c |1.\catco|de`]=2 \|
|00000a30| 63 61 74 63 6f 64 65 20 | 60 5c 7b 3d 31 32 20 5c |catcode |`\{=12 \|
|00000a40| 63 61 74 63 6f 64 65 20 | 60 5c 7d 3d 31 32 0a 5c |catcode |`\}=12.\|
|00000a50| 63 61 74 63 6f 64 65 60 | 5c 5c 3d 31 32 20 7c 67 |catcode`|\\=12 |g|
|00000a60| 64 65 66 7c 40 78 54 65 | 58 63 6f 64 65 23 31 5c |def|@xTe|Xcode#1\|
|00000a70| 65 6e 64 7b 54 65 58 63 | 6f 64 65 7d 5b 23 31 7c |end{TeXc|ode}[#1||
|00000a80| 65 6e 64 5b 54 65 58 63 | 6f 64 65 5d 5d 0a 7c 65 |end[TeXc|ode]].|e|
|00000a90| 6e 64 67 72 6f 75 70 0a | 0a 5c 64 65 66 5c 54 65 |ndgroup.|.\def\Te|
|00000aa0| 58 63 6f 64 65 0a 20 20 | 20 7b 5c 40 76 65 72 62 |Xcode. | {\@verb|
|00000ab0| 61 74 69 6d 20 5c 73 6d | 61 6c 6c 73 6b 69 70 5c |atim \sm|allskip\|
|00000ac0| 68 72 75 6c 65 5c 6d 65 | 64 73 6b 69 70 20 5c 66 |hrule\me|dskip \f|
|00000ad0| 72 65 6e 63 68 73 70 61 | 63 69 6e 67 5c 40 76 6f |renchspa|cing\@vo|
|00000ae0| 62 65 79 73 70 61 63 65 | 73 20 5c 40 78 54 65 58 |beyspace|s \@xTeX|
|00000af0| 63 6f 64 65 7d 0a 5c 64 | 65 66 5c 65 6e 64 54 65 |code}.\d|ef\endTe|
|00000b00| 58 63 6f 64 65 0a 20 20 | 20 7b 5c 6d 65 64 73 6b |Xcode. | {\medsk|
|00000b10| 69 70 5c 68 72 75 6c 65 | 5c 73 6d 61 6c 6c 73 6b |ip\hrule|\smallsk|
|00000b20| 69 70 5c 65 6e 64 74 72 | 69 76 6c 69 73 74 7d 0a |ip\endtr|ivlist}.|
|00000b30| 0a 5c 6d 61 6b 65 61 74 | 6f 74 68 65 72 0a 0a 5c |.\makeat|other..\|
|00000b40| 62 65 67 69 6e 7b 64 6f | 63 75 6d 65 6e 74 7d 0a |begin{do|cument}.|
|00000b50| 0a 5c 6d 61 6b 65 74 69 | 74 6c 65 0a 0a 5c 73 65 |.\maketi|tle..\se|
|00000b60| 63 74 69 6f 6e 7b 57 68 | 79 20 6c 69 73 74 73 3f |ction{Wh|y lists?|
|00000b70| 7d 0a 0a 4f 72 69 67 69 | 6e 61 6c 6c 79 2c 20 49 |}..Origi|nally, I|
|00000b80| 20 77 61 6e 74 65 64 20 | 6c 69 73 74 73 20 69 6e | wanted |lists in|
|00000b90| 20 5c 54 65 58 5c 20 66 | 6f 72 0a 61 20 70 61 70 | \TeX\ f|or.a pap|
|00000ba0| 65 72 20 49 20 77 61 73 | 20 77 72 69 74 69 6e 67 |er I was| writing|
|00000bb0| 20 77 68 69 63 68 20 63 | 6f 6e 74 61 69 6e 65 64 | which c|ontained|
|00000bc0| 20 61 20 6c 6f 74 20 6f | 66 20 66 61 63 74 73 2e | a lot o|f facts.|
|00000bd0| 0a 5c 62 65 67 69 6e 7b | 66 61 63 74 7d 0a 5c 46 |.\begin{|fact}.\F|
|00000be0| 6f 72 77 61 72 64 7b 46 | 61 63 2d 63 6f 77 73 7d |orward{F|ac-cows}|
|00000bf0| 0a 20 20 20 43 6f 77 73 | 20 68 61 76 65 20 66 6f |. Cows| have fo|
|00000c00| 75 72 20 6c 65 67 73 2e | 0a 5c 65 6e 64 7b 66 61 |ur legs.|.\end{fa|
|00000c10| 63 74 7d 0a 5c 62 65 67 | 69 6e 7b 66 61 63 74 7d |ct}.\beg|in{fact}|
|00000c20| 0a 5c 46 6f 72 77 61 72 | 64 7b 46 61 63 2d 70 65 |.\Forwar|d{Fac-pe|
|00000c30| 6f 70 6c 65 7d 0a 20 20 | 20 50 65 6f 70 6c 65 20 |ople}. | People |
|00000c40| 68 61 76 65 20 74 77 6f | 20 6c 65 67 73 2e 0a 5c |have two| legs..\|
|00000c50| 65 6e 64 7b 66 61 63 74 | 7d 0a 5c 62 65 67 69 6e |end{fact|}.\begin|
|00000c60| 7b 66 61 63 74 7d 0a 5c | 46 6f 72 77 61 72 64 7b |{fact}.\|Forward{|
|00000c70| 46 61 63 2d 79 61 77 6e | 7d 0a 20 20 20 4c 6f 74 |Fac-yawn|}. Lot|
|00000c80| 73 20 6f 66 20 66 61 63 | 74 73 20 69 6e 20 61 20 |s of fac|ts in a |
|00000c90| 72 6f 77 20 63 61 6e 20 | 62 65 20 64 75 6c 6c 2e |row can |be dull.|
|00000ca0| 0a 5c 65 6e 64 7b 66 61 | 63 74 7d 0a 54 68 65 73 |.\end{fa|ct}.Thes|
|00000cb0| 65 20 61 72 65 20 67 65 | 6e 65 72 61 74 65 64 20 |e are ge|nerated |
|00000cc0| 77 69 74 68 20 63 6f 6d | 6d 61 6e 64 73 20 6c 69 |with com|mands li|
|00000cd0| 6b 65 0a 5c 62 65 67 69 | 6e 7b 76 65 72 62 61 74 |ke.\begi|n{verbat|
|00000ce0| 69 6d 7d 0a 5c 62 65 67 | 69 6e 7b 66 61 63 74 7d |im}.\beg|in{fact}|
|00000cf0| 0a 5c 46 6f 72 77 61 72 | 64 7b 46 61 63 2d 79 61 |.\Forwar|d{Fac-ya|
|00000d00| 77 6e 7d 0a 20 20 20 4c | 6f 74 73 20 6f 66 20 66 |wn}. L|ots of f|
|00000d10| 61 63 74 73 20 69 6e 20 | 61 20 72 6f 77 20 63 61 |acts in |a row ca|
|00000d20| 6e 20 62 65 20 64 75 6c | 6c 2e 0a 5c 65 6e 64 7b |n be dul|l..\end{|
|00000d30| 66 61 63 74 7d 0a 5c 65 | 6e 64 7b 76 65 72 62 61 |fact}.\e|nd{verba|
|00000d40| 74 69 6d 7d 0a 49 20 63 | 61 6e 20 74 68 65 6e 20 |tim}.I c|an then |
|00000d50| 72 65 66 65 72 20 74 6f | 20 74 68 65 73 65 20 66 |refer to| these f|
|00000d60| 61 63 74 73 20 62 79 20 | 73 61 79 69 6e 67 0a 5c |acts by |saying.\|
|00000d70| 62 65 67 69 6e 7b 76 65 | 72 62 61 74 69 6d 7d 0a |begin{ve|rbatim}.|
|00000d80| 5c 42 79 5b 46 61 63 2d | 79 61 77 6e 2c 46 61 63 |\By[Fac-|yawn,Fac|
|00000d90| 2d 63 6f 77 73 2c 46 61 | 63 2d 70 65 6f 70 6c 65 |-cows,Fa|c-people|
|00000da0| 5d 0a 5c 65 6e 64 7b 76 | 65 72 62 61 74 69 6d 7d |].\end{v|erbatim}|
|00000db0| 0a 74 6f 20 67 65 74 20 | 0a 5c 42 79 5b 46 61 63 |.to get |.\By[Fac|
|00000dc0| 2d 79 61 77 6e 2c 46 61 | 63 2d 63 6f 77 73 2c 46 |-yawn,Fa|c-cows,F|
|00000dd0| 61 63 2d 70 65 6f 70 6c | 65 5d 2e 0a 41 6e 64 20 |ac-peopl|e]..And |
|00000de0| 61 73 20 69 66 20 62 79 | 20 6d 61 67 69 63 2c 20 |as if by| magic, |
|00000df0| 74 68 65 20 66 61 63 74 | 73 20 63 6f 6d 65 20 6f |the fact|s come o|
|00000e00| 75 74 20 73 6f 72 74 65 | 64 2c 20 72 61 74 68 65 |ut sorte|d, rathe|
|00000e10| 72 20 74 68 61 6e 20 69 | 6e 0a 74 68 65 20 6a 75 |r than i|n.the ju|
|00000e20| 6d 62 6c 65 64 20 6f 72 | 64 65 72 20 49 20 74 79 |mbled or|der I ty|
|00000e30| 70 65 64 20 74 68 65 6d | 2e 20 20 54 68 69 73 20 |ped them|. This |
|00000e40| 69 73 20 76 65 72 79 20 | 75 73 65 66 75 6c 2c 20 |is very |useful, |
|00000e50| 61 73 20 49 20 63 61 6e | 0a 72 65 6f 72 67 61 6e |as I can|.reorgan|
|00000e60| 69 7a 65 20 6d 79 20 64 | 6f 63 75 6d 65 6e 74 20 |ize my d|ocument |
|00000e70| 74 6f 20 6d 79 20 68 65 | 61 72 74 27 73 20 63 6f |to my he|art's co|
|00000e80| 6e 74 65 6e 74 2c 20 61 | 6e 64 20 6e 6f 74 20 68 |ntent, a|nd not h|
|00000e90| 61 76 65 20 74 6f 20 77 | 6f 72 72 79 0a 61 62 6f |ave to w|orry.abo|
|00000ea0| 75 74 20 67 65 74 74 69 | 6e 67 20 6d 79 20 66 61 |ut getti|ng my fa|
|00000eb0| 63 74 73 20 73 74 72 61 | 69 67 68 74 2e 20 20 0a |cts stra|ight. .|
|00000ec0| 0a 4f 72 69 67 69 6e 61 | 6c 6c 79 20 49 20 74 72 |.Origina|lly I tr|
|00000ed0| 69 65 64 20 70 72 6f 67 | 72 61 6d 6d 69 6e 67 20 |ied prog|ramming |
|00000ee0| 74 68 69 73 20 73 6f 72 | 74 69 6e 67 20 72 6f 75 |this sor|ting rou|
|00000ef0| 74 69 6e 65 20 69 6e 20 | 5c 54 65 58 27 73 0a 6c |tine in |\TeX's.l|
|00000f00| 69 73 74 20 6d 61 63 72 | 6f 73 2c 20 66 72 6f 6d |ist macr|os, from|
|00000f10| 20 41 70 70 65 6e 64 69 | 78 7e 44 20 6f 66 20 5c | Appendi|x~D of \|
|00000f20| 54 42 2c 20 62 75 74 20 | 49 20 73 6f 6f 6e 20 72 |TB, but |I soon r|
|00000f30| 61 6e 20 69 6e 74 6f 20 | 74 72 6f 75 62 6c 65 2e |an into |trouble.|
|00000f40| 0a 54 68 65 20 70 72 6f | 62 6c 65 6d 20 69 73 20 |.The pro|blem is |
|00000f50| 74 68 61 74 20 61 6c 6c | 20 74 68 65 20 41 70 70 |that all| the App|
|00000f60| 65 6e 64 69 78 7e 44 20 | 6d 61 63 72 6f 73 20 77 |endix~D |macros w|
|00000f70| 6f 72 6b 20 62 79 20 61 | 73 73 69 67 6e 69 6e 67 |ork by a|ssigning|
|00000f80| 0a 76 61 6c 75 65 73 20 | 74 6f 20 6d 61 63 72 6f |.values |to macro|
|00000f90| 73 2e 20 20 46 6f 72 20 | 65 78 61 6d 70 6c 65 3a |s. For |example:|
|00000fa0| 0a 5c 62 65 67 69 6e 7b | 76 65 72 62 61 74 69 6d |.\begin{|verbatim|
|00000fb0| 7d 0a 5c 63 6f 6e 63 61 | 74 65 6e 61 74 65 5c 66 |}.\conca|tenate\f|
|00000fc0| 6f 6f 3d 5c 62 61 72 5c | 62 61 7a 0a 5c 65 6e 64 |oo=\bar\|baz.\end|
|00000fd0| 7b 76 65 72 62 61 74 69 | 6d 7d 0a 65 78 70 61 6e |{verbati|m}.expan|
|00000fe0| 64 73 20 6f 75 74 20 74 | 6f 0a 5c 62 65 67 69 6e |ds out t|o.\begin|
|00000ff0| 7b 76 65 72 62 61 74 69 | 6d 7d 0a 5c 74 61 3d 5c |{verbati|m}.\ta=\|
|00001000| 65 78 70 61 6e 64 61 66 | 74 65 72 7b 5c 62 61 72 |expandaf|ter{\bar|
|00001010| 7d 0a 5c 74 62 3d 5c 65 | 78 70 61 6e 64 61 66 74 |}.\tb=\e|xpandaft|
|00001020| 65 72 7b 5c 62 61 7a 7d | 0a 5c 65 64 65 66 5c 66 |er{\baz}|.\edef\f|
|00001030| 6f 6f 7b 5c 74 68 65 5c | 74 61 5c 74 68 65 5c 74 |oo{\the\|ta\the\t|
|00001040| 62 7d 0a 5c 65 6e 64 7b | 76 65 72 62 61 74 69 6d |b}.\end{|verbatim|
|00001050| 7d 0a 77 68 69 63 68 20 | 61 73 73 69 67 6e 73 20 |}.which |assigns |
|00001060| 74 68 65 20 6d 61 63 72 | 6f 20 5c 76 65 72 62 7c |the macr|o \verb||
|00001070| 5c 66 6f 6f 7c 20 74 68 | 65 20 63 6f 6e 74 65 6e |\foo| th|e conten|
|00001080| 74 73 20 6f 66 20 5c 76 | 65 72 62 7c 5c 62 61 72 |ts of \v|erb|\bar|
|00001090| 7c 0a 66 6f 6c 6c 6f 77 | 65 64 20 62 79 20 74 68 ||.follow|ed by th|
|000010a0| 65 20 63 6f 6e 74 65 6e | 74 73 20 6f 66 20 5c 76 |e conten|ts of \v|
|000010b0| 65 72 62 7c 5c 62 61 7a | 7c 2e 20 20 50 72 6f 67 |erb|\baz||. Prog|
|000010c0| 72 61 6d 6d 69 6e 67 20 | 73 6f 72 74 69 6e 67 20 |ramming |sorting |
|000010d0| 72 6f 75 74 69 6e 65 73 | 0a 28 77 68 69 63 68 20 |routines|.(which |
|000010e0| 61 72 65 20 75 73 75 61 | 6c 6c 79 20 72 65 63 75 |are usua|lly recu|
|000010f0| 72 73 69 76 65 29 20 69 | 6e 20 74 65 72 6d 73 20 |rsive) i|n terms |
|00001100| 6f 66 20 74 68 65 73 65 | 20 6c 69 73 74 73 20 62 |of these| lists b|
|00001110| 65 63 61 6d 65 20 72 61 | 74 68 65 72 0a 70 61 69 |ecame ra|ther.pai|
|00001120| 6e 66 75 6c 2c 20 61 73 | 20 49 20 77 61 73 20 63 |nful, as| I was c|
|00001130| 6f 6e 73 74 61 6e 74 6c | 79 20 68 61 76 69 6e 67 |onstantl|y having|
|00001140| 20 74 6f 20 77 61 74 63 | 68 20 6f 75 74 20 66 6f | to watc|h out fo|
|00001150| 72 20 6c 6f 63 61 6c 20 | 76 61 72 69 61 62 6c 65 |r local |variable|
|00001160| 73 2c 0a 77 6f 72 72 79 | 69 6e 67 20 61 62 6f 75 |s,.worry|ing abou|
|00001170| 74 20 77 68 61 74 20 68 | 61 70 70 65 6e 65 64 20 |t what h|appened |
|00001180| 69 66 20 61 20 6c 6f 63 | 61 6c 20 76 61 72 69 61 |if a loc|al varia|
|00001190| 62 6c 65 20 68 61 64 20 | 74 68 65 20 73 61 6d 65 |ble had |the same|
|000011a0| 20 6e 61 6d 65 0a 61 73 | 20 61 20 67 6c 6f 62 61 | name.as| a globa|
|000011b0| 6c 20 6f 6e 65 2c 20 61 | 6e 64 20 67 65 6e 65 72 |l one, a|nd gener|
|000011c0| 61 6c 6c 79 20 68 61 76 | 69 6e 67 20 61 20 68 61 |ally hav|ing a ha|
|000011d0| 72 64 20 74 69 6d 65 2e | 0a 0a 54 68 65 6e 20 49 |rd time.|..Then I|
|000011e0| 20 68 61 64 20 6f 6e 65 | 20 6f 66 20 74 68 6f 73 | had one| of thos|
|000011f0| 65 20 60 60 66 6c 61 73 | 68 20 6f 66 20 6c 69 67 |e ``flas|h of lig|
|00001200| 68 74 27 27 20 65 78 70 | 65 72 69 65 6e 63 65 73 |ht'' exp|eriences|
|00001210| 20 2d 2d 2d 0a 60 60 59 | 6f 75 20 63 61 6e 20 64 | ---.``Y|ou can d|
|00001220| 6f 20 6c 61 6d 62 64 61 | 2d 63 61 6c 63 75 6c 75 |o lambda|-calculu|
|00001230| 73 20 69 6e 20 5c 54 65 | 58 2c 27 27 20 49 20 74 |s in \Te|X,'' I t|
|00001240| 68 6f 75 67 68 74 2c 0a | 61 6e 64 20 73 69 6e 63 |hought,.|and sinc|
|00001250| 65 20 79 6f 75 20 63 61 | 6e 20 64 6f 20 6c 69 73 |e you ca|n do lis|
|00001260| 74 73 20 64 69 72 65 63 | 74 6c 79 20 69 6e 20 6c |ts direc|tly in l|
|00001270| 61 6d 62 64 61 20 63 61 | 6c 63 75 6c 75 73 2c 20 |ambda ca|lculus, |
|00001280| 0a 79 6f 75 20 73 68 6f | 75 6c 64 20 62 65 20 61 |.you sho|uld be a|
|00001290| 62 6c 65 20 74 6f 20 64 | 6f 20 6c 69 73 74 73 20 |ble to d|o lists |
|000012a0| 73 74 72 61 69 67 68 74 | 66 6f 72 77 61 72 64 6c |straight|forwardl|
|000012b0| 79 20 69 6e 20 5c 54 65 | 58 2e 20 20 41 6e 64 20 |y in \Te|X. And |
|000012c0| 73 6f 20 79 6f 75 0a 63 | 61 6e 2e 20 20 57 65 6c |so you.c|an. Wel|
|000012d0| 6c 2c 20 66 61 69 72 6c | 79 20 73 74 72 61 69 67 |l, fairl|y straig|
|000012e0| 68 74 66 6f 72 77 61 72 | 64 6c 79 20 61 6e 79 77 |htforwar|dly anyw|
|000012f0| 61 79 2e 0a 0a 53 6f 20 | 49 20 77 65 6e 74 20 61 |ay...So |I went a|
|00001300| 6e 64 20 64 69 64 20 61 | 20 62 69 74 20 6f 66 20 |nd did a| bit of |
|00001310| 6d 61 74 68 65 6d 61 74 | 69 63 73 2c 20 61 6e 64 |mathemat|ics, and|
|00001320| 20 64 65 72 69 76 65 64 | 20 74 68 65 20 5c 54 65 | derived| the \Te|
|00001330| 58 5c 20 6d 61 63 72 6f | 73 0a 79 6f 75 20 73 65 |X\ macro|s.you se|
|00001340| 65 20 68 65 72 65 2e 20 | 20 54 68 65 79 20 77 65 |e here. | They we|
|00001350| 72 65 20 66 6f 72 6d 61 | 6c 6c 79 20 76 65 72 69 |re forma|lly veri|
|00001360| 66 69 65 64 2c 20 61 6e | 64 20 77 6f 72 6b 65 64 |fied, an|d worked|
|00001370| 20 66 69 72 73 74 20 74 | 69 6d 65 0a 28 6d 6f 64 | first t|ime.(mod|
|00001380| 75 6c 6f 20 74 79 70 69 | 6e 67 20 65 72 72 6f 72 |ulo typi|ng error|
|00001390| 73 2c 20 6f 66 20 77 68 | 69 63 68 20 74 68 65 72 |s, of wh|ich ther|
|000013a0| 65 20 77 65 72 65 20 74 | 77 6f 29 2e 0a 0a 5c 73 |e were t|wo)...\s|
|000013b0| 65 63 74 69 6f 6e 7b 5c | 54 65 58 27 73 20 6d 6f |ection{\|TeX's mo|
|000013c0| 75 74 68 20 61 6e 64 20 | 5c 54 65 58 27 73 20 73 |uth and |\TeX's s|
|000013d0| 74 6f 6d 61 63 68 7d 0a | 0a 5c 54 65 58 27 73 20 |tomach}.|.\TeX's |
|000013e0| 70 72 6f 67 72 61 6d 6d | 69 6e 67 20 66 61 63 69 |programm|ing faci|
|000013f0| 6c 69 74 69 65 73 20 63 | 6f 6d 65 20 69 6e 20 74 |lities c|ome in t|
|00001400| 77 6f 20 66 6f 72 6d 73 | 20 2d 2d 2d 20 74 68 65 |wo forms| --- the|
|00001410| 72 65 20 61 72 65 20 5c | 54 65 58 27 73 0a 7b 5c |re are \|TeX's.{\|
|00001420| 65 6d 20 6d 61 63 72 6f | 73 5c 2f 7d 20 77 68 69 |em macro|s\/} whi|
|00001430| 63 68 20 61 72 65 20 65 | 78 70 61 6e 64 65 64 20 |ch are e|xpanded |
|00001440| 69 6e 20 69 74 73 20 6d | 6f 75 74 68 2c 20 61 6e |in its m|outh, an|
|00001450| 64 20 73 6f 6d 65 20 61 | 64 64 69 74 69 6f 6e 61 |d some a|dditiona|
|00001460| 6c 20 0a 7b 5c 65 6d 20 | 61 73 73 69 67 6e 6d 65 |l .{\em |assignme|
|00001470| 6e 74 5c 2f 7d 20 6f 70 | 65 72 61 74 69 6f 6e 73 |nt\/} op|erations|
|00001480| 20 6c 69 6b 65 20 5c 76 | 65 72 62 7c 5c 64 65 66 | like \v|erb|\def|
|00001490| 7c 20 77 68 69 63 68 20 | 74 61 6b 65 20 70 6c 61 || which |take pla|
|000014a0| 63 65 20 69 6e 20 74 68 | 65 0a 73 74 6f 6d 61 63 |ce in th|e.stomac|
|000014b0| 68 2e 20 20 5c 54 65 58 | 5c 20 63 61 6e 20 6f 66 |h. \TeX|\ can of|
|000014c0| 74 65 6e 20 73 70 72 69 | 6e 67 20 73 75 72 70 72 |ten spri|ng surpr|
|000014d0| 69 73 65 73 20 6f 6e 20 | 79 6f 75 20 61 73 20 65 |ises on |you as e|
|000014e0| 78 61 63 74 6c 79 20 77 | 68 61 74 0a 67 65 74 73 |xactly w|hat.gets|
|000014f0| 20 65 76 61 6c 75 61 74 | 65 64 20 77 68 65 72 65 | evaluat|ed where|
|00001500| 2e 0a 46 6f 72 20 65 78 | 61 6d 70 6c 65 2c 20 69 |..For ex|ample, i|
|00001510| 6e 20 5c 4c 61 54 65 58 | 5c 20 49 20 63 61 6e 20 |n \LaTeX|\ I can |
|00001520| 70 75 74 20 64 6f 77 6e | 20 61 0a 6c 61 62 65 6c |put down| a.label|
|00001530| 20 62 79 20 73 61 79 69 | 6e 67 20 5c 76 65 72 62 | by sayi|ng \verb|
|00001540| 7c 5c 6c 61 62 65 6c 7b | 48 65 72 65 7d 7c 2e 0a ||\label{|Here}|..|
|00001550| 5c 6c 61 62 65 6c 7b 48 | 65 72 65 7d 0a 54 68 65 |\label{H|ere}.The|
|00001560| 6e 20 49 20 63 61 6e 20 | 72 65 66 65 72 20 62 61 |n I can |refer ba|
|00001570| 63 6b 20 74 6f 20 74 68 | 61 74 20 6c 61 62 65 6c |ck to th|at label|
|00001580| 20 62 79 20 73 61 79 69 | 6e 67 0a 5c 76 65 72 62 | by sayi|ng.\verb|
|00001590| 7c 53 65 63 74 69 6f 6e | 7e 5c 72 65 66 7b 48 65 ||Section|~\ref{He|
|000015a0| 72 65 7d 7c 2c 20 77 68 | 69 63 68 0a 70 72 6f 64 |re}|, wh|ich.prod|
|000015b0| 75 63 65 73 20 53 65 63 | 74 69 6f 6e 7e 5c 72 65 |uces Sec|tion~\re|
|000015c0| 66 7b 48 65 72 65 7d 2e | 20 20 55 6e 66 6f 72 74 |f{Here}.| Unfort|
|000015d0| 75 6e 61 74 65 6c 79 2c | 20 5c 76 65 72 62 7c 5c |unately,| \verb|\|
|000015e0| 72 65 66 7b 48 65 72 65 | 7d 7c 20 64 6f 65 73 0a |ref{Here|}| does.|
|000015f0| 7b 5c 65 6d 20 6e 6f 74 | 5c 2f 7d 20 65 78 70 61 |{\em not|\/} expa|
|00001600| 6e 64 20 6f 75 74 20 74 | 6f 20 7b 5c 74 74 5c 72 |nd out t|o {\tt\r|
|00001610| 65 66 7b 48 65 72 65 7d | 7d 21 20 20 49 6e 73 74 |ef{Here}|}! Inst|
|00001620| 65 61 64 2c 20 69 74 20 | 65 78 70 61 6e 64 73 20 |ead, it |expands |
|00001630| 6f 75 74 20 74 6f 3a 0a | 5c 62 65 67 69 6e 7b 76 |out to:.|\begin{v|
|00001640| 65 72 62 61 74 69 6d 7d | 0a 5c 65 64 65 66 5c 40 |erbatim}|.\edef\@|
|00001650| 74 65 6d 70 61 7b 5c 40 | 6e 61 6d 65 75 73 65 7b |tempa{\@|nameuse{|
|00001660| 72 40 48 65 72 65 7d 7d | 0a 5c 65 78 70 61 6e 64 |r@Here}}|.\expand|
|00001670| 61 66 74 65 72 5c 40 63 | 61 72 5c 40 74 65 6d 70 |after\@c|ar\@temp|
|00001680| 61 5c 40 6e 69 6c 5c 6e | 75 6c 6c 0a 5c 65 6e 64 |a\@nil\n|ull.\end|
|00001690| 7b 76 65 72 62 61 74 69 | 6d 7d 0a 54 68 69 73 20 |{verbati|m}.This |
|000016a0| 6d 65 61 6e 73 20 74 68 | 61 74 20 49 20 63 61 6e |means th|at I can|
|000016b0| 27 74 20 73 61 79 20 0a | 5c 62 65 67 69 6e 7b 76 |'t say .|\begin{v|
|000016c0| 65 72 62 61 74 69 6d 7d | 0a 5c 69 66 6e 75 6d 5c |erbatim}|.\ifnum\|
|000016d0| 72 65 66 7b 48 65 72 65 | 7d 3c 34 20 48 65 6c 6c |ref{Here|}<4 Hell|
|000016e0| 6f 5c 66 69 0a 5c 65 6e | 64 7b 76 65 72 62 61 74 |o\fi.\en|d{verbat|
|000016f0| 69 6d 7d 20 0a 61 6e 64 | 20 68 6f 70 65 20 74 68 |im} .and| hope th|
|00001700| 61 74 20 74 68 69 73 20 | 77 69 6c 6c 20 65 78 70 |at this |will exp|
|00001710| 61 6e 64 20 6f 75 74 20 | 74 6f 20 48 65 6c 6c 6f |and out |to Hello|
|00001720| 2e 20 20 49 6e 73 74 65 | 61 64 20 49 20 0a 67 65 |. Inste|ad I .ge|
|00001730| 74 20 61 6e 20 65 72 72 | 6f 72 20 6d 65 73 73 61 |t an err|or messa|
|00001740| 67 65 2e 20 20 57 68 69 | 63 68 20 69 73 20 72 61 |ge. Whi|ch is ra|
|00001750| 74 68 65 72 20 61 20 70 | 69 74 79 2c 20 61 73 20 |ther a p|ity, as |
|00001760| 5c 54 65 58 27 73 20 6d | 6f 75 74 68 20 69 73 0a |\TeX's m|outh is.|
|00001770| 71 75 69 74 65 20 61 20 | 70 6f 77 65 72 66 75 6c |quite a |powerful|
|00001780| 20 70 72 6f 67 72 61 6d | 6d 69 6e 67 20 6c 61 6e | program|ming lan|
|00001790| 67 75 61 67 65 20 28 61 | 73 20 70 6f 77 65 72 66 |guage (a|s powerf|
|000017a0| 75 6c 20 61 73 20 61 20 | 54 75 72 69 6e 67 20 4d |ul as a |Turing M|
|000017b0| 61 63 68 69 6e 65 20 69 | 6e 0a 66 61 63 74 29 2e |achine i|n.fact).|
|000017c0| 20 20 0a 0a 5c 73 65 63 | 74 69 6f 6e 7b 46 75 6e | ..\sec|tion{Fun|
|000017d0| 63 74 69 6f 6e 73 7d 0a | 0a 41 20 7b 5c 65 6d 20 |ctions}.|.A {\em |
|000017e0| 66 75 6e 63 74 69 6f 6e | 5c 2f 7d 20 69 73 20 61 |function|\/} is a|
|000017f0| 20 6d 61 74 68 65 6d 61 | 74 69 63 61 6c 20 6f 62 | mathema|tical ob|
|00001800| 6a 65 63 74 20 74 68 61 | 74 20 74 61 6b 65 73 20 |ject tha|t takes |
|00001810| 69 6e 20 61 6e 20 61 72 | 67 75 6d 65 6e 74 0a 28 |in an ar|gument.(|
|00001820| 77 68 69 63 68 20 63 6f | 75 6c 64 20 77 65 6c 6c |which co|uld well|
|00001830| 20 62 65 20 61 6e 6f 74 | 68 65 72 20 66 75 6e 63 | be anot|her func|
|00001840| 74 69 6f 6e 29 20 61 6e | 64 20 72 65 74 75 72 6e |tion) an|d return|
|00001850| 73 20 73 6f 6d 65 20 6f | 74 68 65 72 20 6d 61 74 |s some o|ther mat|
|00001860| 68 65 6d 61 74 69 63 61 | 6c 0a 6f 62 6a 65 63 74 |hematica|l.object|
|00001870| 2e 20 20 46 6f 72 20 65 | 78 61 6d 70 6c 65 20 74 |. For e|xample t|
|00001880| 68 65 20 66 75 6e 63 74 | 69 6f 6e 20 24 4e 6f 74 |he funct|ion $Not|
|00001890| 24 20 74 61 6b 65 73 20 | 69 6e 20 61 20 62 6f 6f |$ takes |in a boo|
|000018a0| 6c 65 61 6e 20 61 6e 64 | 20 72 65 74 75 72 6e 73 |lean and| returns|
|000018b0| 0a 69 74 73 20 63 6f 6d | 70 6c 65 6d 65 6e 74 2e |.its com|plement.|
|000018c0| 20 20 49 27 6c 6c 20 77 | 72 69 74 65 20 66 75 6e | I'll w|rite fun|
|000018d0| 63 74 69 6f 6e 20 61 70 | 70 6c 69 63 61 74 69 6f |ction ap|plicatio|
|000018e0| 6e 20 77 69 74 68 6f 75 | 74 20 62 72 61 63 6b 65 |n withou|t bracke|
|000018f0| 74 73 2c 0a 73 6f 20 24 | 4e 6f 74 7e 62 24 20 69 |ts,.so $|Not~b$ i|
|00001900| 73 20 74 68 65 20 62 6f | 6f 6c 65 61 6e 20 63 6f |s the bo|olean co|
|00001910| 6d 70 6c 65 6d 65 6e 74 | 20 6f 66 20 24 62 24 2e |mplement| of $b$.|
|00001920| 20 20 0a 0a 46 75 6e 63 | 74 69 6f 6e 20 61 70 70 | ..Func|tion app|
|00001930| 6c 69 63 61 74 69 6f 6e | 0a 62 69 6e 64 73 20 74 |lication|.binds t|
|00001940| 6f 20 74 68 65 20 6c 65 | 66 74 2c 20 73 6f 20 24 |o the le|ft, so $|
|00001950| 66 7e 61 7e 62 24 20 69 | 73 20 24 28 66 7e 61 29 |f~a~b$ i|s $(f~a)|
|00001960| 7e 62 24 20 72 61 74 68 | 65 72 20 74 68 61 6e 20 |~b$ rath|er than |
|00001970| 24 66 7e 28 61 7e 62 29 | 24 2e 0a 46 6f 72 20 65 |$f~(a~b)|$..For e|
|00001980| 78 61 6d 70 6c 65 2c 20 | 24 4f 72 7e 61 7e 62 24 |xample, |$Or~a~b$|
|00001990| 20 69 73 20 74 68 65 20 | 62 6f 6f 6c 65 61 6e 20 | is the |boolean |
|000019a0| 6f 72 20 6f 66 20 24 61 | 24 20 61 6e 64 20 24 62 |or of $a|$ and $b|
|000019b0| 24 2c 20 61 6e 64 0a 24 | 4f 72 7e 54 72 75 65 24 |$, and.$|Or~True$|
|000019c0| 20 69 73 20 61 20 70 65 | 72 66 65 63 74 6c 79 20 | is a pe|rfectly |
|000019d0| 67 6f 6f 64 20 66 75 6e | 63 74 69 6f 6e 20 74 68 |good fun|ction th|
|000019e0| 61 74 20 74 61 6b 65 73 | 20 69 6e 20 61 20 62 6f |at takes| in a bo|
|000019f0| 6f 6c 65 61 6e 0a 61 6e | 64 20 72 65 74 75 72 6e |olean.an|d return|
|00001a00| 73 20 24 54 72 75 65 24 | 2e 0a 0a 54 68 65 20 6f |s $True$|...The o|
|00001a10| 62 76 69 6f 75 73 20 65 | 71 75 69 76 61 6c 65 6e |bvious e|quivalen|
|00001a20| 74 73 20 6f 66 20 66 75 | 6e 63 74 69 6f 6e 73 20 |ts of fu|nctions |
|00001a30| 69 6e 20 5c 54 65 58 5c | 20 61 72 65 20 6d 61 63 |in \TeX\| are mac|
|00001a40| 72 6f 73 20 2d 2d 2d 0a | 69 66 20 49 20 64 65 66 |ros ---.|if I def|
|00001a50| 69 6e 65 20 61 20 66 75 | 6e 63 74 69 6f 6e 20 24 |ine a fu|nction $|
|00001a60| 46 6f 6f 24 20 74 6f 20 | 62 65 3a 0a 5c 62 65 67 |Foo$ to |be:.\beg|
|00001a70| 69 6e 7b 65 71 6e 61 72 | 72 61 79 2a 7d 0a 20 20 |in{eqnar|ray*}. |
|00001a80| 20 46 6f 6f 7e 78 20 20 | 26 20 20 3d 20 20 26 20 | Foo~x |& = & |
|00001a90| 20 54 72 75 65 0a 5c 65 | 6e 64 7b 65 71 6e 61 72 | True.\e|nd{eqnar|
|00001aa0| 72 61 79 2a 7d 0a 74 68 | 65 6e 20 69 74 20 63 61 |ray*}.th|en it ca|
|00001ab0| 6e 20 62 65 20 74 72 61 | 6e 73 6c 61 74 65 64 20 |n be tra|nslated |
|00001ac0| 69 6e 74 6f 20 5c 54 65 | 58 5c 20 61 73 3a 0a 5c |into \Te|X\ as:.\|
|00001ad0| 62 65 67 69 6e 7b 76 65 | 72 62 61 74 69 6d 7d 0a |begin{ve|rbatim}.|
|00001ae0| 5c 64 65 66 5c 46 6f 6f | 23 31 7b 5c 54 72 75 65 |\def\Foo|#1{\True|
|00001af0| 7d 0a 5c 65 6e 64 7b 76 | 65 72 62 61 74 69 6d 7d |}.\end{v|erbatim}|
|00001b00| 0a 53 6f 20 77 68 65 72 | 65 20 24 46 6f 6f 24 20 |.So wher|e $Foo$ |
|00001b10| 69 73 20 61 20 66 75 6e | 63 74 69 6f 6e 20 74 68 |is a fun|ction th|
|00001b20| 61 74 20 74 61 6b 65 73 | 20 69 6e 20 6f 6e 65 20 |at takes| in one |
|00001b30| 61 72 67 75 6d 65 6e 74 | 2c 20 5c 76 65 72 62 7c |argument|, \verb||
|00001b40| 5c 46 6f 6f 7c 0a 69 73 | 20 61 20 6d 61 63 72 6f |\Foo|.is| a macro|
|00001b50| 20 74 68 61 74 20 74 61 | 6b 65 73 20 69 6e 20 6f | that ta|kes in o|
|00001b60| 6e 65 20 70 61 72 61 6d | 65 74 65 72 2e 20 20 4e |ne param|eter. N|
|00001b70| 6f 74 68 69 6e 67 20 68 | 61 73 20 63 68 61 6e 67 |othing h|as chang|
|00001b80| 65 64 20 65 78 63 65 70 | 74 0a 74 68 65 20 6a 61 |ed excep|t.the ja|
|00001b90| 72 67 6f 6e 20 61 6e 64 | 20 74 68 65 20 66 6f 6e |rgon and| the fon|
|00001ba0| 74 2e 20 20 5c 54 65 58 | 5c 20 6d 61 63 72 6f 73 |t. \TeX|\ macros|
|00001bb0| 20 63 61 6e 20 65 76 65 | 6e 20 62 65 20 70 61 72 | can eve|n be par|
|00001bc0| 74 69 61 6c 6c 79 20 61 | 70 70 6c 69 65 64 2c 0a |tially a|pplied,.|
|00001bd0| 66 6f 72 20 65 78 61 6d | 70 6c 65 20 69 66 20 77 |for exam|ple if w|
|00001be0| 65 20 64 65 66 69 6e 65 | 64 3a 0a 5c 62 65 67 69 |e define|d:.\begi|
|00001bf0| 6e 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 20 20 20 |n{eqnarr|ay*}. |
|00001c00| 42 61 7a 20 20 26 20 20 | 3d 20 20 26 20 20 4f 72 |Baz & |= & Or|
|00001c10| 7e 54 72 75 65 0a 5c 65 | 6e 64 7b 65 71 6e 61 72 |~True.\e|nd{eqnar|
|00001c20| 72 61 79 2a 7d 0a 74 68 | 65 6e 20 74 68 65 20 5c |ray*}.th|en the \|
|00001c30| 54 65 58 5c 20 65 71 75 | 69 76 61 6c 65 6e 74 20 |TeX\ equ|ivalent |
|00001c40| 77 6f 75 6c 64 20 62 65 | 0a 5c 62 65 67 69 6e 7b |would be|.\begin{|
|00001c50| 76 65 72 62 61 74 69 6d | 7d 0a 5c 64 65 66 5c 42 |verbatim|}.\def\B|
|00001c60| 61 7a 7b 5c 4f 72 5c 54 | 72 75 65 7d 0a 5c 65 6e |az{\Or\T|rue}.\en|
|00001c70| 64 7b 76 65 72 62 61 74 | 69 6d 7d 0a 4f 6e 63 65 |d{verbat|im}.Once|
|00001c80| 20 5c 76 65 72 62 7c 5c | 42 61 7a 7c 20 69 73 20 | \verb|\|Baz| is |
|00001c90| 65 78 70 61 6e 64 65 64 | 2c 20 69 74 20 77 69 6c |expanded|, it wil|
|00001ca0| 6c 20 65 78 70 65 63 74 | 20 74 6f 20 62 65 20 67 |l expect| to be g|
|00001cb0| 69 76 65 6e 20 61 20 70 | 61 72 61 6d 65 74 65 72 |iven a p|arameter|
|00001cc0| 2c 0a 62 75 74 20 77 68 | 65 6e 20 77 65 20 61 72 |,.but wh|en we ar|
|00001cd0| 65 20 64 65 66 69 6e 69 | 6e 67 20 74 68 69 6e 67 |e defini|ng thing|
|00001ce0| 73 2c 20 77 65 20 63 61 | 6e 20 67 6f 20 61 72 6f |s, we ca|n go aro|
|00001cf0| 75 6e 64 20 70 61 72 74 | 69 61 6c 6c 79 20 61 70 |und part|ially ap|
|00001d00| 70 6c 79 69 6e 67 0a 74 | 68 65 6d 20 61 6c 6c 20 |plying.t|hem all |
|00001d10| 77 65 20 6c 69 6b 65 2e | 0a 0a 48 65 72 65 2c 20 |we like.|..Here, |
|00001d20| 49 27 6d 20 75 73 69 6e | 67 20 24 3d 24 20 77 69 |I'm usin|g $=$ wi|
|00001d30| 74 68 6f 75 74 20 66 6f | 72 6d 61 6c 6c 79 20 64 |thout fo|rmally d|
|00001d40| 65 66 69 6e 69 6e 67 20 | 69 74 2c 20 77 68 69 63 |efining |it, whic|
|00001d50| 68 20 69 73 20 72 61 74 | 68 65 72 0a 6e 61 75 67 |h is rat|her.naug|
|00001d60| 68 74 79 2e 20 20 49 66 | 20 49 20 73 61 79 20 24 |hty. If| I say $|
|00001d70| 78 20 3d 20 79 24 2c 20 | 74 68 69 73 20 6d 65 61 |x = y$, |this mea|
|00001d80| 6e 73 20 0a 60 60 67 69 | 76 65 6e 20 65 6e 6f 75 |ns .``gi|ven enou|
|00001d90| 67 68 20 70 61 72 61 6d | 65 74 65 72 73 2c 20 24 |gh param|eters, $|
|00001da0| 78 24 20 61 6e 64 20 24 | 79 24 20 77 69 6c 6c 20 |x$ and $|y$ will |
|00001db0| 65 76 65 6e 74 75 61 6c | 6c 79 0a 65 78 70 61 6e |eventual|ly.expan|
|00001dc0| 64 20 6f 75 74 20 74 6f | 20 74 68 65 20 73 61 6d |d out to| the sam|
|00001dd0| 65 20 74 68 69 6e 67 2e | 27 27 20 20 46 6f 72 20 |e thing.|'' For |
|00001de0| 65 78 61 6d 70 6c 65 20 | 24 46 6f 6f 20 3d 20 42 |example |$Foo = B|
|00001df0| 61 7a 24 2c 20 62 65 63 | 61 75 73 65 0a 66 6f 72 |az$, bec|ause.for|
|00001e00| 20 61 6e 79 20 24 78 24 | 2c 0a 5c 62 65 67 69 6e | any $x$|,.\begin|
|00001e10| 7b 65 71 6e 61 72 72 61 | 79 2a 7d 0a 20 20 20 5c |{eqnarra|y*}. \|
|00001e20| 73 74 61 72 74 7b 46 6f | 6f 7e 78 7d 0a 20 20 20 |start{Fo|o~x}. |
|00001e30| 26 20 20 3d 20 20 26 20 | 20 54 72 75 65 20 20 5c |& = & | True \|
|00001e40| 5c 0a 20 20 20 26 20 20 | 3d 20 20 26 20 20 4f 72 |\. & |= & Or|
|00001e50| 7e 54 72 75 65 7e 78 20 | 20 5c 5c 0a 20 20 20 26 |~True~x | \\. &|
|00001e60| 20 20 3d 20 20 26 20 20 | 42 61 7a 7e 78 0a 5c 65 | = & |Baz~x.\e|
|00001e70| 6e 64 7b 65 71 6e 61 72 | 72 61 79 2a 7d 0a 4e 6f |nd{eqnar|ray*}.No|
|00001e80| 72 6d 61 6c 6c 79 2c 20 | 66 75 6e 63 74 69 6f 6e |rmally, |function|
|00001e90| 73 20 68 61 76 65 20 74 | 6f 20 7b 72 65 73 70 65 |s have t|o {respe|
|00001ea0| 63 74 20 65 71 75 61 6c | 69 74 79 5c 2f 7d 20 77 |ct equal|ity\/} w|
|00001eb0| 68 69 63 68 20 6d 65 61 | 6e 73 20 74 68 61 74 3a |hich mea|ns that:|
|00001ec0| 0a 5c 62 65 67 69 6e 7b | 69 74 65 6d 69 7a 65 7d |.\begin{|itemize}|
|00001ed0| 0a 5c 69 74 65 6d 20 69 | 66 20 24 78 20 3d 20 79 |.\item i|f $x = y|
|00001ee0| 24 20 74 68 65 6e 20 24 | 66 7e 78 20 3d 20 66 7e |$ then $|f~x = f~|
|00001ef0| 79 24 2c 20 61 6e 64 0a | 5c 69 74 65 6d 20 69 66 |y$, and.|\item if|
|00001f00| 20 24 78 24 20 72 65 73 | 70 65 63 74 73 20 65 71 | $x$ res|pects eq|
|00001f10| 75 61 6c 69 74 79 2c 20 | 74 68 65 6e 20 24 66 7e |uality, |then $f~|
|00001f20| 78 24 20 72 65 73 70 65 | 63 74 73 20 65 71 75 61 |x$ respe|cts equa|
|00001f30| 6c 69 74 79 2e 0a 5c 65 | 6e 64 7b 69 74 65 6d 69 |lity..\e|nd{itemi|
|00001f40| 7a 65 7d 0a 48 6f 77 65 | 76 65 72 2c 20 73 6f 6d |ze}.Howe|ver, som|
|00001f50| 65 20 5c 54 65 58 5c 20 | 63 6f 6e 74 72 6f 6c 20 |e \TeX\ |control |
|00001f60| 73 65 71 75 65 6e 63 65 | 73 20 64 6f 6e 27 74 20 |sequence|s don't |
|00001f70| 6f 62 65 79 20 74 68 69 | 73 2e 20 20 46 6f 72 20 |obey thi|s. For |
|00001f80| 65 78 61 6d 70 6c 65 2c | 0a 5c 76 65 72 62 7c 5c |example,|.\verb|\|
|00001f90| 73 74 72 69 6e 67 5c 46 | 6f 6f 7c 20 61 6e 64 20 |string\F|oo| and |
|00001fa0| 5c 76 65 72 62 7c 5c 73 | 74 72 69 6e 67 5c 42 61 |\verb|\s|tring\Ba|
|00001fb0| 7a 7c 20 61 72 65 20 64 | 69 66 66 65 72 65 6e 74 |z| are d|ifferent|
|00001fc0| 2c 20 65 76 65 6e 20 74 | 68 6f 75 67 68 0a 24 46 |, even t|hough.$F|
|00001fd0| 6f 6f 20 3d 20 42 61 7a | 24 2e 20 20 48 65 6e 63 |oo = Baz|$. Henc|
|00001fe0| 65 20 24 73 74 72 69 6e | 67 24 20 64 6f 65 73 6e |e $strin|g$ doesn|
|00001ff0| 27 74 20 72 65 73 70 65 | 63 74 20 65 71 75 61 6c |'t respe|ct equal|
|00002000| 69 74 79 2e 0a 55 6e 6c | 65 73 73 20 6f 74 68 65 |ity..Unl|ess othe|
|00002010| 72 77 69 73 65 20 73 74 | 61 74 65 64 2c 20 77 65 |rwise st|ated, we|
|00002020| 20 77 6f 6e 27 74 20 61 | 73 73 75 6d 65 20 66 75 | won't a|ssume fu|
|00002030| 6e 63 74 69 6f 6e 73 20 | 72 65 73 70 65 63 74 20 |nctions |respect |
|00002040| 65 71 75 61 6c 69 74 79 | 2c 0a 61 6c 74 68 6f 75 |equality|,.althou|
|00002050| 67 68 20 61 6c 6c 20 74 | 68 65 20 66 75 6e 63 74 |gh all t|he funct|
|00002060| 69 6f 6e 73 20 64 65 66 | 69 6e 65 64 20 68 65 72 |ions def|ined her|
|00002070| 65 20 64 6f 2e 0a 0a 41 | 6c 6c 20 6f 66 20 6f 75 |e do...A|ll of ou|
|00002080| 72 20 66 75 6e 63 74 69 | 6f 6e 73 20 68 61 76 65 |r functi|ons have|
|00002090| 20 63 61 70 69 74 61 6c | 20 6c 65 74 74 65 72 73 | capital| letters|
|000020a0| 2c 20 73 6f 20 74 68 61 | 74 20 74 68 65 69 72 20 |, so tha|t their |
|000020b0| 5c 54 65 58 5c 20 65 71 | 75 69 76 61 6c 65 6e 74 |\TeX\ eq|uivalent|
|000020c0| 73 0a 28 5c 76 65 72 62 | 7c 5c 4e 6f 74 7c 2c 20 |s.(\verb||\Not|, |
|000020d0| 5c 76 65 72 62 7c 5c 4f | 72 7c 20 61 6e 64 20 73 |\verb|\O|r| and s|
|000020e0| 6f 20 6f 6e 29 20 64 6f | 6e 27 74 20 63 6c 61 73 |o on) do|n't clas|
|000020f0| 68 20 77 69 74 68 20 73 | 74 61 6e 64 61 72 64 20 |h with s|tandard |
|00002100| 5c 54 65 58 5c 20 6f 72 | 0a 5c 4c 61 54 65 58 5c |\TeX\ or|.\LaTeX\|
|00002110| 20 6d 61 63 72 6f 73 2e | 0a 0a 5c 73 75 62 73 65 | macros.|..\subse|
|00002120| 63 74 69 6f 6e 7b 49 64 | 65 6e 74 69 74 79 7d 0a |ction{Id|entity}.|
|00002130| 0a 54 68 65 20 73 69 6d | 70 6c 65 73 74 20 66 75 |.The sim|plest fu|
|00002140| 6e 63 74 69 6f 6e 20 69 | 73 20 74 68 65 20 7b 5c |nction i|s the {\|
|00002150| 65 6d 20 69 64 65 6e 74 | 69 74 79 5c 2f 7d 20 66 |em ident|ity\/} f|
|00002160| 75 6e 63 74 69 6f 6e 2c | 20 63 61 6c 6c 65 64 0a |unction,| called.|
|00002170| 24 49 64 65 6e 74 69 74 | 79 24 20 66 75 6e 6e 69 |$Identit|y$ funni|
|00002180| 6c 79 20 65 6e 6f 75 67 | 68 2c 20 77 68 69 63 68 |ly enoug|h, which|
|00002190| 20 69 73 20 64 65 66 69 | 6e 65 64 3a 0a 5c 62 65 | is defi|ned:.\be|
|000021a0| 67 69 6e 7b 65 71 6e 61 | 72 72 61 79 2a 7d 0a 20 |gin{eqna|rray*}. |
|000021b0| 20 20 49 64 65 6e 74 69 | 74 79 7e 78 20 20 26 20 | Identi|ty~x & |
|000021c0| 20 3d 20 20 26 20 20 5c | 49 64 65 6e 74 69 74 79 | = & \|Identity|
|000021d0| 7b 78 7d 0a 5c 65 6e 64 | 7b 65 71 6e 61 72 72 61 |{x}.\end|{eqnarra|
|000021e0| 79 2a 7d 0a 54 68 69 73 | 2c 20 69 74 20 6d 75 73 |y*}.This|, it mus|
|000021f0| 74 20 62 65 20 61 64 6d | 69 74 74 65 64 2c 20 69 |t be adm|itted, i|
|00002200| 73 20 61 20 70 72 65 74 | 74 79 20 64 75 6c 6c 20 |s a pret|ty dull |
|00002210| 66 75 6e 63 74 69 6f 6e | 2c 20 62 75 74 0a 69 74 |function|, but.it|
|00002220| 27 73 20 61 20 75 73 65 | 66 75 6c 20 62 61 73 69 |'s a use|ful basi|
|00002230| 63 20 63 6f 6d 62 69 6e | 61 74 6f 72 2e 20 20 49 |c combin|ator. I|
|00002240| 74 20 63 61 6e 20 62 65 | 20 69 6d 70 6c 65 6d 65 |t can be| impleme|
|00002250| 6e 74 65 64 0a 69 6e 20 | 5c 54 65 58 5c 20 71 75 |nted.in |\TeX\ qu|
|00002260| 69 74 65 20 73 69 6d 70 | 6c 79 2e 0a 5c 62 65 67 |ite simp|ly..\beg|
|00002270| 69 6e 7b 54 65 58 63 6f | 64 65 7d 0a 5c 64 65 66 |in{TeXco|de}.\def|
|00002280| 5c 49 64 65 6e 74 69 74 | 79 23 31 7b 23 31 7d 0a |\Identit|y#1{#1}.|
|00002290| 5c 65 6e 64 7b 54 65 58 | 63 6f 64 65 7d 0a 54 68 |\end{TeX|code}.Th|
|000022a0| 65 20 72 75 6c 65 73 20 | 61 72 6f 75 6e 64 20 74 |e rules |around t|
|000022b0| 68 69 73 20 64 65 66 69 | 6e 69 74 69 6f 6e 20 6d |his defi|nition m|
|000022c0| 65 61 6e 20 74 68 61 74 | 20 69 74 20 69 73 20 61 |ean that| it is a|
|000022d0| 63 74 75 61 6c 6c 79 20 | 70 61 72 74 20 6f 66 0a |ctually |part of.|
|000022e0| 5c 76 65 72 62 7c 4c 61 | 6d 62 64 61 2e 73 74 79 |\verb|La|mbda.sty|
|000022f0| 7c 20 61 6e 64 20 6e 6f | 74 20 6a 75 73 74 20 61 || and no|t just a|
|00002300| 6e 6f 74 68 65 72 20 65 | 78 61 6d 70 6c 65 2e 0a |nother e|xample..|
|00002310| 0a 5c 73 75 62 73 65 63 | 74 69 6f 6e 7b 45 72 72 |.\subsec|tion{Err|
|00002320| 6f 72 7d 0a 0a 57 68 65 | 72 65 61 73 20 24 49 64 |or}..Whe|reas $Id|
|00002330| 65 6e 74 69 74 79 24 20 | 64 6f 65 73 20 6e 6f 74 |entity$ |does not|
|00002340| 68 69 6e 67 20 69 6e 20 | 61 20 66 61 69 72 6c 79 |hing in |a fairly|
|00002350| 20 70 6c 65 61 73 61 6e | 74 20 73 6f 72 74 20 6f | pleasan|t sort o|
|00002360| 66 20 77 61 79 2c 0a 24 | 45 72 72 6f 72 24 20 64 |f way,.$|Error$ d|
|00002370| 6f 65 73 20 6e 6f 74 68 | 69 6e 67 20 69 6e 20 61 |oes noth|ing in a|
|00002380| 20 70 61 72 74 69 63 75 | 6c 61 72 6c 79 20 62 72 | particu|larly br|
|00002390| 75 74 61 6c 20 61 6e 64 | 20 68 61 72 73 68 20 66 |utal and| harsh f|
|000023a0| 61 73 68 69 6f 6e 2e 0a | 4d 61 74 68 65 6d 61 74 |ashion..|Mathemat|
|000023b0| 69 63 61 6c 6c 79 2c 20 | 24 45 72 72 6f 72 24 20 |ically, |$Error$ |
|000023c0| 69 73 20 74 68 65 20 66 | 75 6e 63 74 69 6f 6e 20 |is the f|unction |
|000023d0| 74 68 61 74 20 64 65 73 | 74 72 6f 79 73 20 65 76 |that des|troys ev|
|000023e0| 65 72 79 74 68 69 6e 67 | 0a 65 6c 73 65 20 69 6e |erything|.else in|
|000023f0| 20 66 72 6f 6e 74 20 6f | 66 20 69 74 2e 20 20 49 | front o|f it. I|
|00002400| 74 20 69 73 20 6f 66 74 | 65 6e 20 77 72 69 74 74 |t is oft|en writt|
|00002410| 65 6e 20 61 73 20 24 5c | 70 65 72 70 24 2e 0a 5c |en as $\|perp$..\|
|00002420| 62 65 67 69 6e 7b 65 71 | 6e 61 72 72 61 79 2a 7d |begin{eq|narray*}|
|00002430| 0a 20 20 20 45 72 72 6f | 72 7e 78 20 20 26 20 20 |. Erro|r~x & |
|00002440| 3d 20 20 26 20 20 45 72 | 72 6f 72 0a 5c 65 6e 64 |= & Er|ror.\end|
|00002450| 7b 65 71 6e 61 72 72 61 | 79 2a 7d 0a 49 6e 20 70 |{eqnarra|y*}.In p|
|00002460| 72 61 63 74 69 63 65 2c | 20 64 65 73 74 72 6f 79 |ractice,| destroy|
|00002470| 69 6e 67 20 74 68 65 20 | 65 6e 74 69 72 65 20 64 |ing the |entire d|
|00002480| 6f 63 75 6d 65 6e 74 20 | 77 68 65 6e 20 77 65 20 |ocument |when we |
|00002490| 68 69 74 20 6f 6e 65 20 | 65 72 72 6f 72 0a 69 73 |hit one |error.is|
|000024a0| 20 61 20 62 69 74 20 6d | 75 63 68 2c 20 73 6f 20 | a bit m|uch, so |
|000024b0| 77 65 27 6c 6c 20 6a 75 | 73 74 20 70 72 69 6e 74 |we'll ju|st print|
|000024c0| 20 6f 75 74 20 61 6e 20 | 65 72 72 6f 72 20 6d 65 | out an |error me|
|000024d0| 73 73 61 67 65 2e 0a 54 | 68 65 20 75 73 65 72 20 |ssage..T|he user |
|000024e0| 63 61 6e 20 63 61 72 72 | 79 20 6f 6e 20 70 61 73 |can carr|y on pas|
|000024f0| 74 20 61 6e 20 65 72 72 | 6f 72 20 61 74 20 74 68 |t an err|or at th|
|00002500| 65 69 72 20 6f 77 6e 20 | 72 69 73 6b 2c 20 61 73 |eir own |risk, as|
|00002510| 20 74 68 65 20 63 6f 64 | 65 0a 77 69 6c 6c 20 6e | the cod|e.will n|
|00002520| 6f 20 6c 6f 6e 67 65 72 | 20 62 65 20 66 6f 72 6d |o longer| be form|
|00002530| 61 6c 6c 79 20 76 65 72 | 69 66 69 65 64 2e 0a 5c |ally ver|ified..\|
|00002540| 62 65 67 69 6e 7b 54 65 | 58 63 6f 64 65 7d 0a 5c |begin{Te|Xcode}.\|
|00002550| 64 65 66 5c 45 72 72 6f | 72 0a 20 20 20 7b 5c 65 |def\Erro|r. {\e|
|00002560| 72 72 6d 65 73 73 61 67 | 65 7b 41 62 61 6e 64 6f |rrmessag|e{Abando|
|00002570| 6e 20 76 65 72 69 66 69 | 63 61 74 69 6f 6e 20 61 |n verifi|cation a|
|00002580| 6c 6c 20 0a 20 20 20 20 | 20 20 20 20 20 20 20 20 |ll . | |
|00002590| 20 20 20 20 79 65 20 77 | 68 6f 20 65 6e 74 65 72 | ye w|ho enter|
|000025a0| 20 68 65 72 65 7d 7d 0a | 5c 65 6e 64 7b 54 65 58 | here}}.|\end{TeX|
|000025b0| 63 6f 64 65 7d 0a 4d 61 | 79 62 65 20 74 68 69 73 |code}.Ma|ybe this|
|000025c0| 20 66 75 6e 63 74 69 6f | 6e 20 6f 75 67 68 74 20 | functio|n ought |
|000025d0| 74 6f 20 72 65 74 75 72 | 6e 20 61 20 6d 6f 72 65 |to retur|n a more|
|000025e0| 20 75 73 65 66 75 6c 20 | 65 72 72 6f 72 20 6d 65 | useful |error me|
|000025f0| 73 73 61 67 65 20 5c 6c | 64 6f 74 73 0a 0a 5c 73 |ssage \l|dots..\s|
|00002600| 75 62 73 65 63 74 69 6f | 6e 7b 46 69 72 73 74 20 |ubsectio|n{First |
|00002610| 61 6e 64 20 53 65 63 6f | 6e 64 7d 0a 0a 54 77 6f |and Seco|nd}..Two|
|00002620| 20 6f 74 68 65 72 20 62 | 61 73 69 63 20 66 75 6e | other b|asic fun|
|00002630| 63 74 69 6f 6e 73 20 61 | 72 65 20 24 46 69 72 73 |ctions a|re $Firs|
|00002640| 74 24 20 61 6e 64 20 24 | 53 65 63 6f 6e 64 24 2c |t$ and $|Second$,|
|00002650| 20 62 6f 74 68 20 6f 66 | 20 77 68 69 63 68 0a 74 | both of| which.t|
|00002660| 61 6b 65 20 69 6e 20 74 | 77 6f 20 61 72 67 75 6d |ake in t|wo argum|
|00002670| 65 6e 74 73 2c 20 61 6e | 64 20 64 6f 20 74 68 65 |ents, an|d do the|
|00002680| 20 6f 62 76 69 6f 75 73 | 20 74 68 69 6e 67 2e 20 | obvious| thing. |
|00002690| 20 54 68 65 79 20 61 72 | 65 20 64 65 66 69 6e 65 | They ar|e define|
|000026a0| 64 3a 0a 5c 62 65 67 69 | 6e 7b 65 71 6e 61 72 72 |d:.\begi|n{eqnarr|
|000026b0| 61 79 2a 7d 0a 20 20 20 | 20 46 69 72 73 74 7e 78 |ay*}. | First~x|
|000026c0| 7e 79 20 20 26 20 20 3d | 20 20 26 20 20 78 20 20 |~y & =| & x |
|000026d0| 5c 5c 0a 20 20 20 53 65 | 63 6f 6e 64 7e 78 7e 79 |\\. Se|cond~x~y|
|000026e0| 20 20 26 20 20 3d 20 20 | 26 20 20 79 0a 5c 65 6e | & = |& y.\en|
|000026f0| 64 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 57 65 20 |d{eqnarr|ay*}.We |
|00002700| 63 6f 75 6c 64 2c 20 69 | 6e 0a 66 61 63 74 2c 20 |could, i|n.fact, |
|00002710| 64 65 66 69 6e 65 20 24 | 53 65 63 6f 6e 64 24 20 |define $|Second$ |
|00002720| 69 6e 20 74 65 72 6d 73 | 20 6f 66 20 24 49 64 65 |in terms| of $Ide|
|00002730| 6e 74 69 74 79 24 20 61 | 6e 64 20 24 46 69 72 73 |ntity$ a|nd $Firs|
|00002740| 74 24 2e 20 20 0a 46 6f | 72 20 61 6e 79 20 24 78 |t$. .Fo|r any $x|
|00002750| 24 20 61 6e 64 20 24 79 | 24 2c 0a 5c 62 65 67 69 |$ and $y|$,.\begi|
|00002760| 6e 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 20 20 20 |n{eqnarr|ay*}. |
|00002770| 5c 73 74 61 72 74 7b 46 | 69 72 73 74 7e 49 64 65 |\start{F|irst~Ide|
|00002780| 6e 74 69 74 79 7e 78 7e | 79 7d 20 20 0a 20 20 20 |ntity~x~|y} . |
|00002790| 26 20 20 3d 20 20 26 20 | 20 49 64 65 6e 74 69 74 |& = & | Identit|
|000027a0| 79 7e 79 20 20 5c 5c 0a | 20 20 20 26 20 20 3d 20 |y~y \\.| & = |
|000027b0| 20 26 20 20 79 20 20 5c | 5c 0a 20 20 20 26 20 20 | & y \|\. & |
|000027c0| 3d 20 20 26 20 20 53 65 | 63 6f 6e 64 7e 78 7e 79 |= & Se|cond~x~y|
|000027d0| 0a 5c 65 6e 64 7b 65 71 | 6e 61 72 72 61 79 2a 7d |.\end{eq|narray*}|
|000027e0| 0a 53 6f 20 24 46 69 72 | 73 74 7e 49 64 65 6e 74 |.So $Fir|st~Ident|
|000027f0| 69 74 79 20 3d 20 53 65 | 63 6f 6e 64 24 2e 20 20 |ity = Se|cond$. |
|00002800| 54 68 69 73 20 6d 65 61 | 6e 73 20 74 68 61 74 20 |This mea|ns that |
|00002810| 61 6e 79 77 68 65 72 65 | 20 69 6e 20 6f 75 72 20 |anywhere| in our |
|00002820| 5c 54 65 58 5c 20 63 6f | 64 65 0a 77 65 20 68 61 |\TeX\ co|de.we ha|
|00002830| 76 65 20 5c 76 65 72 62 | 7c 5c 46 69 72 73 74 5c |ve \verb||\First\|
|00002840| 49 64 65 6e 74 69 74 79 | 7c 20 77 65 20 63 6f 75 |Identity|| we cou|
|00002850| 6c 64 20 72 65 70 6c 61 | 63 65 20 69 74 20 62 79 |ld repla|ce it by|
|00002860| 20 5c 76 65 72 62 7c 5c | 53 65 63 6f 6e 64 7c 2e | \verb|\|Second|.|
|00002870| 0a 54 68 69 73 20 69 73 | 20 70 65 72 68 61 70 73 |.This is| perhaps|
|00002880| 20 6e 6f 74 20 74 68 65 | 20 6d 6f 73 74 20 61 73 | not the| most as|
|00002890| 74 6f 6e 69 73 68 69 6e | 67 20 5c 54 65 58 5c 20 |tonishin|g \TeX\ |
|000028a0| 66 61 63 74 20 6b 6e 6f | 77 6e 20 74 6f 20 68 75 |fact kno|wn to hu|
|000028b0| 6d 61 6e 69 74 79 2c 0a | 62 75 74 20 74 68 69 73 |manity,.|but this|
|000028c0| 20 73 6f 72 74 20 6f 66 | 20 70 72 6f 6f 66 20 64 | sort of| proof d|
|000028d0| 69 64 20 65 6e 61 62 6c | 65 20 6d 6f 72 65 20 63 |id enabl|e more c|
|000028e0| 6f 6d 70 6c 65 78 20 62 | 69 74 73 20 6f 66 20 5c |omplex b|its of \|
|000028f0| 54 65 58 5c 20 74 6f 20 | 62 65 0a 76 65 72 69 66 |TeX\ to |be.verif|
|00002900| 69 65 64 20 62 65 66 6f | 72 65 20 74 68 65 79 20 |ied befo|re they |
|00002910| 77 65 72 65 20 72 75 6e | 2e 0a 0a 54 68 65 20 5c |were run|...The \|
|00002920| 54 65 58 5c 20 64 65 66 | 69 6e 69 74 69 6f 6e 73 |TeX\ def|initions|
|00002930| 20 6f 66 20 5c 76 65 72 | 62 7c 5c 46 69 72 73 74 | of \ver|b|\First|
|00002940| 7c 20 61 6e 64 20 5c 76 | 65 72 62 7c 5c 53 65 63 || and \v|erb|\Sec|
|00002950| 6f 6e 64 7c 20 61 72 65 | 20 70 72 65 74 74 79 0a |ond| are| pretty.|
|00002960| 6f 62 76 69 6f 75 73 2e | 0a 5c 62 65 67 69 6e 7b |obvious.|.\begin{|
|00002970| 54 65 58 63 6f 64 65 7d | 0a 5c 64 65 66 5c 46 69 |TeXcode}|.\def\Fi|
|00002980| 72 73 74 23 31 23 32 7b | 23 31 7d 0a 5c 64 65 66 |rst#1#2{|#1}.\def|
|00002990| 5c 53 65 63 6f 6e 64 23 | 31 23 32 7b 23 32 7d 0a |\Second#|1#2{#2}.|
|000029a0| 5c 65 6e 64 7b 54 65 58 | 63 6f 64 65 7d 0a 4e 6f |\end{TeX|code}.No|
|000029b0| 74 65 20 74 68 61 74 20 | 69 6e 20 5c 54 65 58 5c |te that |in \TeX\|
|000029c0| 2c 20 5c 76 65 72 62 7c | 5c 46 69 72 73 74 5c 66 |, \verb||\First\f|
|000029d0| 6f 6f 5c 62 61 72 7c 20 | 65 78 70 61 6e 64 73 20 |oo\bar| |expands |
|000029e0| 6f 75 74 20 74 6f 0a 5c | 76 65 72 62 7c 5c 66 6f |out to.\|verb|\fo|
|000029f0| 6f 7c 20 7b 5c 65 6d 20 | 77 69 74 68 6f 75 74 5c |o| {\em |without\|
|00002a00| 2f 7d 20 65 78 70 61 6e | 64 69 6e 67 20 6f 75 74 |/} expan|ding out|
|00002a10| 20 5c 76 65 72 62 7c 5c | 62 61 72 7c 2e 0a 54 68 | \verb|\|bar|..Th|
|00002a20| 69 73 20 69 73 20 76 65 | 72 79 20 75 73 65 66 75 |is is ve|ry usefu|
|00002a30| 6c 2c 20 61 73 20 77 65 | 20 63 61 6e 20 77 72 69 |l, as we| can wri|
|00002a40| 74 65 20 6d 61 63 72 6f | 73 20 74 68 61 74 20 77 |te macro|s that w|
|00002a50| 6f 75 6c 64 20 74 61 6b | 65 0a 66 6f 72 65 76 65 |ould tak|e.foreve|
|00002a60| 72 20 61 6e 64 20 61 20 | 64 61 79 20 74 6f 20 72 |r and a |day to r|
|00002a70| 75 6e 20 69 66 20 74 68 | 65 79 20 65 78 70 61 6e |un if th|ey expan|
|00002a80| 64 65 64 20 61 6c 6c 20 | 74 68 65 69 72 20 61 72 |ded all |their ar|
|00002a90| 67 75 6d 65 6e 74 73 2c | 0a 62 75 74 20 77 68 69 |guments,|.but whi|
|00002aa0| 63 68 20 61 63 74 75 61 | 6c 6c 79 20 74 65 72 6d |ch actua|lly term|
|00002ab0| 69 6e 61 74 65 20 71 75 | 69 74 65 20 71 75 69 63 |inate qu|ite quic|
|00002ac0| 6b 6c 79 2e 20 20 54 68 | 69 73 20 69 73 20 63 61 |kly. Th|is is ca|
|00002ad0| 6c 6c 65 64 0a 7b 5c 65 | 6d 20 6c 61 7a 79 20 65 |lled.{\e|m lazy e|
|00002ae0| 76 61 6c 75 61 74 69 6f | 6e 5c 2f 7d 20 62 79 20 |valuatio|n\/} by |
|00002af0| 74 68 65 20 66 75 6e 63 | 74 69 6f 6e 61 6c 20 70 |the func|tional p|
|00002b00| 72 6f 67 72 61 6d 6d 69 | 6e 67 20 63 6f 6d 6d 75 |rogrammi|ng commu|
|00002b10| 6e 69 74 79 2e 0a 0a 5c | 73 75 62 73 65 63 74 69 |nity...\|subsecti|
|00002b20| 6f 6e 7b 43 6f 6d 70 6f | 73 65 7d 0a 0a 47 69 76 |on{Compo|se}..Giv|
|00002b30| 65 6e 20 74 77 6f 20 66 | 75 6e 63 74 69 6f 6e 73 |en two f|unctions|
|00002b40| 20 24 66 24 20 61 6e 64 | 20 24 67 24 20 77 65 20 | $f$ and| $g$ we |
|00002b50| 77 6f 75 6c 64 20 6c 69 | 6b 65 20 74 6f 20 62 65 |would li|ke to be|
|00002b60| 20 61 62 6c 65 20 74 6f | 20 7b 5c 65 6d 20 63 6f | able to| {\em co|
|00002b70| 6d 70 6f 73 65 5c 2f 7d | 0a 74 68 65 6d 20 74 6f |mpose\/}|.them to|
|00002b80| 20 70 72 6f 64 75 63 65 | 20 61 20 66 75 6e 63 74 | produce| a funct|
|00002b90| 69 6f 6e 20 74 68 61 74 | 20 66 69 72 73 74 20 61 |ion that| first a|
|00002ba0| 70 70 6c 69 65 73 20 24 | 67 24 20 74 68 65 6e 20 |pplies $|g$ then |
|00002bb0| 61 70 70 6c 69 65 73 20 | 24 66 24 2e 0a 4e 6f 72 |applies |$f$..Nor|
|00002bc0| 6d 61 6c 6c 79 2c 20 74 | 68 69 73 20 69 73 20 77 |mally, t|his is w|
|00002bd0| 72 69 74 74 65 6e 20 61 | 73 20 24 66 20 5c 63 69 |ritten a|s $f \ci|
|00002be0| 72 63 20 67 24 2c 20 62 | 75 74 20 75 6e 66 6f 72 |rc g$, b|ut unfor|
|00002bf0| 74 75 6e 61 74 65 6c 79 | 20 5c 54 65 58 5c 20 64 |tunately| \TeX\ d|
|00002c00| 6f 65 73 6e 27 74 0a 68 | 61 76 65 20 69 6e 66 69 |oesn't.h|ave infi|
|00002c10| 78 20 66 75 6e 63 74 69 | 6f 6e 73 2c 20 73 6f 20 |x functi|ons, so |
|00002c20| 77 65 27 6c 6c 20 68 61 | 76 65 20 74 6f 20 77 72 |we'll ha|ve to wr|
|00002c30| 69 74 65 20 69 74 20 24 | 43 6f 6d 70 6f 73 65 7e |ite it $|Compose~|
|00002c40| 66 7e 67 24 2e 0a 5c 62 | 65 67 69 6e 7b 65 71 6e |f~g$..\b|egin{eqn|
|00002c50| 61 72 72 61 79 2a 7d 0a | 20 20 20 43 6f 6d 70 6f |array*}.| Compo|
|00002c60| 73 65 7e 66 7e 67 7e 78 | 20 20 26 20 20 3d 20 20 |se~f~g~x| & = |
|00002c70| 26 20 20 66 7e 28 67 7e | 78 29 0a 5c 65 6e 64 7b |& f~(g~|x).\end{|
|00002c80| 65 71 6e 61 72 72 61 79 | 2a 7d 0a 3e 46 72 6f 6d |eqnarray|*}.>From|
|00002c90| 20 74 68 69 73 20 64 65 | 66 69 6e 69 74 69 6f 6e | this de|finition|
|00002ca0| 2c 20 77 65 20 63 61 6e | 20 64 65 64 75 63 65 20 |, we can| deduce |
|00002cb0| 74 68 61 74 20 24 43 6f | 6d 70 6f 73 65 24 20 69 |that $Co|mpose$ i|
|00002cc0| 73 20 61 73 73 6f 63 69 | 61 74 69 76 65 3a 0a 5c |s associ|ative:.\|
|00002cd0| 62 65 67 69 6e 7b 65 71 | 6e 61 72 72 61 79 2a 7d |begin{eq|narray*}|
|00002ce0| 0a 20 20 20 5c 73 74 61 | 72 74 7b 43 6f 6d 70 6f |. \sta|rt{Compo|
|00002cf0| 73 65 7e 28 43 6f 6d 70 | 6f 73 65 7e 66 7e 67 29 |se~(Comp|ose~f~g)|
|00002d00| 7e 68 7d 20 20 0a 20 20 | 20 26 20 20 3d 20 20 26 |~h} . | & = &|
|00002d10| 20 20 43 6f 6d 70 6f 73 | 65 7e 66 7e 28 43 6f 6d | Compos|e~f~(Com|
|00002d20| 70 6f 73 65 7e 67 7e 68 | 29 0a 5c 65 6e 64 7b 65 |pose~g~h|).\end{e|
|00002d30| 71 6e 61 72 72 61 79 2a | 7d 0a 61 6e 64 20 24 49 |qnarray*|}.and $I|
|00002d40| 64 65 6e 74 69 74 79 24 | 20 69 73 20 74 68 65 20 |dentity$| is the |
|00002d50| 6c 65 66 74 20 75 6e 69 | 74 20 6f 66 20 24 43 6f |left uni|t of $Co|
|00002d60| 6d 70 6f 73 65 24 3a 0a | 5c 62 65 67 69 6e 7b 65 |mpose$:.|\begin{e|
|00002d70| 71 6e 61 72 72 61 79 2a | 7d 0a 20 20 20 20 20 20 |qnarray*|}. |
|00002d80| 20 20 43 6f 6d 70 6f 73 | 65 7e 49 64 65 6e 74 69 | Compos|e~Identi|
|00002d90| 74 79 7e 66 20 20 26 20 | 20 3d 20 20 26 20 20 66 |ty~f & | = & f|
|00002da0| 20 0a 5c 65 6e 64 7b 65 | 71 6e 61 72 72 61 79 2a | .\end{e|qnarray*|
|00002db0| 7d 0a 54 68 65 20 72 65 | 61 64 65 72 20 6d 61 79 |}.The re|ader may|
|00002dc0| 20 77 6f 6e 64 65 72 20 | 77 68 79 20 24 49 64 65 | wonder |why $Ide|
|00002dd0| 6e 74 69 74 79 24 20 69 | 73 20 63 61 6c 6c 65 64 |ntity$ i|s called|
|00002de0| 20 61 20 7b 5c 65 6d 20 | 6c 65 66 74 5c 2f 7d 20 | a {\em |left\/} |
|00002df0| 75 6e 69 74 0a 65 76 65 | 6e 20 74 68 6f 75 67 68 |unit.eve|n though|
|00002e00| 20 69 74 20 6f 63 63 75 | 72 73 20 6f 6e 20 74 68 | it occu|rs on th|
|00002e10| 65 20 72 69 67 68 74 20 | 6f 66 20 74 68 65 20 24 |e right |of the $|
|00002e20| 43 6f 6d 70 6f 73 65 24 | 20 2d 2d 2d 20 74 68 69 |Compose$| --- thi|
|00002e30| 73 20 69 73 20 61 20 73 | 69 64 65 2d 65 66 66 65 |s is a s|ide-effe|
|00002e40| 63 74 0a 6f 66 20 75 73 | 69 6e 67 20 70 72 65 66 |ct.of us|ing pref|
|00002e50| 69 78 20 6e 6f 74 61 74 | 69 6f 6e 73 20 77 68 65 |ix notat|ions whe|
|00002e60| 72 65 20 69 6e 66 69 78 | 20 69 73 20 6d 6f 72 65 |re infix| is more|
|00002e70| 20 6e 6f 72 6d 61 6c 2e | 20 20 54 68 65 20 69 6e | normal.| The in|
|00002e80| 66 69 78 20 76 65 72 73 | 69 6f 6e 0a 6f 66 20 74 |fix vers|ion.of t|
|00002e90| 68 69 73 20 65 71 75 61 | 74 69 6f 6e 20 69 73 3a |his equa|tion is:|
|00002ea0| 0a 5c 62 65 67 69 6e 7b | 65 71 6e 61 72 72 61 79 |.\begin{|eqnarray|
|00002eb0| 2a 7d 0a 20 20 20 49 64 | 65 6e 74 69 74 79 20 5c |*}. Id|entity \|
|00002ec0| 63 69 72 63 20 66 20 20 | 26 20 20 3d 20 20 26 20 |circ f |& = & |
|00002ed0| 20 66 0a 5c 65 6e 64 7b | 65 71 6e 61 72 72 61 79 | f.\end{|eqnarray|
|00002ee0| 2a 7d 0a 73 6f 20 24 49 | 64 65 6e 74 69 74 79 24 |*}.so $I|dentity$|
|00002ef0| 20 69 73 20 69 6e 64 65 | 65 64 20 6f 6e 20 74 68 | is inde|ed on th|
|00002f00| 65 20 6c 65 66 74 20 6f | 66 20 74 68 65 20 63 6f |e left o|f the co|
|00002f10| 6d 70 6f 73 69 74 69 6f | 6e 2e 0a 0a 24 43 6f 6d |mpositio|n...$Com|
|00002f20| 70 6f 73 65 24 20 63 61 | 6e 20 62 65 20 69 6d 70 |pose$ ca|n be imp|
|00002f30| 6c 65 6d 65 6e 74 65 64 | 20 69 6e 20 5c 54 65 58 |lemented| in \TeX|
|00002f40| 5c 20 61 73 0a 5c 62 65 | 67 69 6e 7b 54 65 58 63 |\ as.\be|gin{TeXc|
|00002f50| 6f 64 65 7d 0a 5c 64 65 | 66 5c 43 6f 6d 70 6f 73 |ode}.\de|f\Compos|
|00002f60| 65 23 31 23 32 23 33 7b | 23 31 7b 23 32 7b 23 33 |e#1#2#3{|#1{#2{#3|
|00002f70| 7d 7d 7d 0a 5c 65 6e 64 | 7b 54 65 58 63 6f 64 65 |}}}.\end|{TeXcode|
|00002f80| 7d 0a 0a 5c 73 75 62 73 | 65 63 74 69 6f 6e 7b 54 |}..\subs|ection{T|
|00002f90| 77 69 64 64 6c 65 7d 0a | 0a 59 65 74 20 61 6e 6f |widdle}.|.Yet ano|
|00002fa0| 74 68 65 72 20 75 73 65 | 66 75 6c 20 6c 69 74 74 |ther use|ful litt|
|00002fb0| 6c 65 20 66 75 6e 63 74 | 69 6f 6e 20 69 73 20 24 |le funct|ion is $|
|00002fc0| 54 77 69 64 64 6c 65 24 | 2c 20 77 68 69 63 68 20 |Twiddle$|, which |
|00002fd0| 74 61 6b 65 73 20 69 6e | 20 0a 61 20 66 75 6e 63 |takes in| .a func|
|00002fe0| 74 69 6f 6e 20 61 6e 64 | 20 72 65 76 65 72 73 65 |tion and| reverse|
|00002ff0| 73 20 74 68 65 20 6f 72 | 64 65 72 20 74 68 61 74 |s the or|der that|
|00003000| 20 66 75 6e 63 74 69 6f | 6e 20 74 61 6b 65 73 20 | functio|n takes |
|00003010| 69 74 73 20 28 66 69 72 | 73 74 20 74 77 6f 29 0a |its (fir|st two).|
|00003020| 61 72 67 75 6d 65 6e 74 | 73 2e 0a 5c 62 65 67 69 |argument|s..\begi|
|00003030| 6e 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 20 20 20 |n{eqnarr|ay*}. |
|00003040| 54 77 69 64 64 6c 65 7e | 66 7e 78 7e 79 20 20 26 |Twiddle~|f~x~y &|
|00003050| 20 20 3d 20 20 26 20 20 | 66 7e 79 7e 78 0a 5c 65 | = & |f~y~x.\e|
|00003060| 6e 64 7b 65 71 6e 61 72 | 72 61 79 2a 7d 0a 41 67 |nd{eqnar|ray*}.Ag|
|00003070| 61 69 6e 2c 20 74 68 65 | 72 65 20 61 72 65 6e 27 |ain, the|re aren'|
|00003080| 74 20 6d 61 6e 79 20 69 | 6d 6d 65 64 69 61 74 65 |t many i|mmediate|
|00003090| 20 75 73 65 73 20 66 6f | 72 20 73 75 63 68 20 61 | uses fo|r such a|
|000030a0| 20 66 75 6e 63 74 69 6f | 6e 2c 20 62 75 74 20 69 | functio|n, but i|
|000030b0| 74 27 6c 6c 0a 63 6f 6d | 65 20 69 6e 20 68 61 6e |t'll.com|e in han|
|000030c0| 64 79 20 6c 61 74 65 72 | 20 6f 6e 2e 20 20 49 74 |dy later| on. It|
|000030d0| 20 73 61 74 69 73 66 69 | 65 73 20 74 68 65 20 70 | satisfi|es the p|
|000030e0| 72 6f 70 65 72 74 69 65 | 73 0a 5c 62 65 67 69 6e |ropertie|s.\begin|
|000030f0| 7b 65 71 6e 61 72 72 61 | 79 2a 7d 0a 20 20 20 20 |{eqnarra|y*}. |
|00003100| 20 20 20 20 20 20 20 20 | 20 20 54 77 69 64 64 6c | | Twiddl|
|00003110| 65 7e 46 69 72 73 74 20 | 20 26 20 20 3d 20 20 26 |e~First | & = &|
|00003120| 20 20 53 65 63 6f 6e 64 | 20 20 5c 5c 0a 20 20 20 | Second| \\. |
|00003130| 20 20 20 20 20 20 20 20 | 20 20 54 77 69 64 64 6c | | Twiddl|
|00003140| 65 7e 53 65 63 6f 6e 64 | 20 20 26 20 20 3d 20 20 |e~Second| & = |
|00003150| 26 20 20 46 69 72 73 74 | 20 20 5c 5c 0a 20 20 20 |& First| \\. |
|00003160| 20 43 6f 6d 70 6f 73 65 | 7e 54 77 69 64 64 6c 65 | Compose|~Twiddle|
|00003170| 7e 54 77 69 64 64 6c 65 | 20 20 26 20 20 3d 20 20 |~Twiddle| & = |
|00003180| 26 20 20 49 64 65 6e 74 | 69 74 79 0a 5c 65 6e 64 |& Ident|ity.\end|
|00003190| 7b 65 71 6e 61 72 72 61 | 79 2a 7d 0a 49 74 73 20 |{eqnarra|y*}.Its |
|000031a0| 5c 54 65 58 5c 20 65 71 | 75 69 76 61 6c 65 6e 74 |\TeX\ eq|uivalent|
|000031b0| 20 69 73 0a 5c 62 65 67 | 69 6e 7b 54 65 58 63 6f | is.\beg|in{TeXco|
|000031c0| 64 65 7d 0a 5c 64 65 66 | 5c 54 77 69 64 64 6c 65 |de}.\def|\Twiddle|
|000031d0| 23 31 23 32 23 33 7b 23 | 31 7b 23 33 7d 7b 23 32 |#1#2#3{#|1{#3}{#2|
|000031e0| 7d 7d 0a 5c 65 6e 64 7b | 54 65 58 63 6f 64 65 7d |}}.\end{|TeXcode}|
|000031f0| 0a 54 68 69 73 20 66 75 | 6e 63 74 69 6f 6e 20 69 |.This fu|nction i|
|00003200| 73 20 63 61 6c 6c 65 64 | 20 60 60 74 77 69 64 64 |s called| ``twidd|
|00003210| 6c 65 27 27 20 62 65 63 | 61 75 73 65 20 69 74 20 |le'' bec|ause it |
|00003220| 69 73 20 73 6f 6d 65 74 | 69 6d 65 73 20 77 72 69 |is somet|imes wri|
|00003230| 74 74 65 6e 0a 24 5c 77 | 69 64 65 74 69 6c 64 65 |tten.$\w|idetilde|
|00003240| 20 66 24 20 28 61 6e 64 | 20 24 5c 73 69 6d 24 20 | f$ (and| $\sim$ |
|00003250| 69 73 20 70 72 6f 6e 6f | 75 6e 63 65 64 20 60 60 |is prono|unced ``|
|00003260| 74 77 69 64 64 6c 65 27 | 27 29 2e 20 20 0a 49 74 |twiddle'|'). .It|
|00003270| 20 61 6c 73 6f 20 74 77 | 69 64 64 6c 65 73 20 69 | also tw|iddles i|
|00003280| 74 73 20 61 72 67 75 6d | 65 6e 74 73 20 61 72 6f |ts argum|ents aro|
|00003290| 75 6e 64 2c 0a 77 68 69 | 63 68 20 69 73 20 71 75 |und,.whi|ch is qu|
|000032a0| 69 74 65 20 6e 69 63 65 | 20 69 66 20 79 6f 75 72 |ite nice| if your|
|000032b0| 20 73 65 6e 73 65 20 6f | 66 20 68 75 6d 6f 75 72 | sense o|f humour|
|000032c0| 20 72 75 6e 73 20 74 6f | 20 61 70 70 61 6c 6c 69 | runs to| appalli|
|000032d0| 6e 67 20 70 75 6e 73 2e | 0a 0a 5c 73 65 63 74 69 |ng puns.|..\secti|
|000032e0| 6f 6e 7b 42 6f 6f 6c 65 | 61 6e 73 7d 0a 0a 41 73 |on{Boole|ans}..As|
|000032f0| 20 77 65 27 72 65 20 74 | 72 79 69 6e 67 20 74 6f | we're t|rying to|
|00003300| 20 70 72 6f 67 72 61 6d | 20 61 20 73 6f 72 74 69 | program| a sorti|
|00003310| 6e 67 20 72 6f 75 74 69 | 6e 65 2c 20 69 74 20 77 |ng routi|ne, it w|
|00003320| 6f 75 6c 64 20 62 65 20 | 6e 69 63 65 20 74 6f 0a |ould be |nice to.|
|00003330| 62 65 20 61 62 6c 65 20 | 74 6f 20 64 65 66 69 6e |be able |to defin|
|00003340| 65 20 6f 72 64 65 72 69 | 6e 67 73 20 6f 6e 20 74 |e orderi|ngs on t|
|00003350| 68 69 6e 67 73 2c 20 61 | 6e 64 20 74 6f 20 64 6f |hings, a|nd to do|
|00003360| 20 74 68 69 73 20 77 65 | 20 6e 65 65 64 20 73 6f | this we| need so|
|00003370| 6d 65 0a 72 65 70 72 65 | 73 65 6e 74 61 74 69 6f |me.repre|sentatio|
|00003380| 6e 20 6f 66 20 62 6f 6f | 6c 65 61 6e 20 76 61 72 |n of boo|lean var|
|00003390| 69 61 62 6c 65 73 2e 20 | 20 55 6e 66 6f 72 74 75 |iables. | Unfortu|
|000033a0| 6e 61 74 65 6c 79 20 5c | 54 65 58 5c 20 64 6f 65 |nately \|TeX\ doe|
|000033b0| 73 6e 27 74 20 68 61 76 | 65 20 61 20 74 79 70 65 |sn't hav|e a type|
|000033c0| 0a 66 6f 72 20 62 6f 6f | 6c 65 61 6e 73 2c 20 73 |.for boo|leans, s|
|000033d0| 6f 20 77 65 27 6c 6c 20 | 68 61 76 65 20 74 6f 20 |o we'll |have to |
|000033e0| 69 6e 76 65 6e 74 20 6f | 75 72 20 6f 77 6e 2e 20 |invent o|ur own. |
|000033f0| 20 57 65 27 6c 6c 0a 69 | 6d 70 6c 65 6d 65 6e 74 | We'll.i|mplement|
|00003400| 20 61 20 62 6f 6f 6c 65 | 61 6e 20 61 73 20 61 20 | a boole|an as a |
|00003410| 66 75 6e 63 74 69 6f 6e | 20 24 62 24 20 6f 66 20 |function| $b$ of |
|00003420| 74 68 65 20 66 6f 72 6d | 0a 5c 62 65 67 69 6e 7b |the form|.\begin{|
|00003430| 65 71 6e 61 72 72 61 79 | 2a 7d 0a 20 20 20 62 7e |eqnarray|*}. b~|
|00003440| 78 7e 79 20 20 26 20 20 | 0a 20 20 20 3d 20 20 26 |x~y & |. = &|
|00003450| 20 20 0a 20 20 20 5c 6c | 65 66 74 5c 7b 0a 20 20 | . \l|eft\{. |
|00003460| 20 20 20 20 5c 62 65 67 | 69 6e 7b 61 72 72 61 79 | \beg|in{array|
|00003470| 7d 7b 6c 6c 7d 0a 20 20 | 20 20 20 20 20 20 20 78 |}{ll}. | x|
|00003480| 20 20 26 20 20 5c 6d 62 | 6f 78 7b 69 66 20 24 62 | & \mb|ox{if $b|
|00003490| 24 20 69 73 20 74 72 75 | 65 7d 20 20 5c 5c 0a 20 |$ is tru|e} \\. |
|000034a0| 20 20 20 20 20 20 20 20 | 79 20 20 26 20 20 5c 6d | |y & \m|
|000034b0| 62 6f 78 7b 6f 74 68 65 | 72 77 69 73 65 7d 0a 20 |box{othe|rwise}. |
|000034c0| 20 20 20 20 20 5c 65 6e | 64 7b 61 72 72 61 79 7d | \en|d{array}|
|000034d0| 0a 20 20 20 5c 72 69 67 | 68 74 2e 0a 5c 65 6e 64 |. \rig|ht..\end|
|000034e0| 7b 65 71 6e 61 72 72 61 | 79 2a 7d 0a 4d 6f 72 65 |{eqnarra|y*}.More|
|000034f0| 20 66 6f 72 6d 61 6c 6c | 79 2c 20 61 20 0a 62 6f | formall|y, a .bo|
|00003500| 6f 6c 65 61 6e 20 24 62 | 24 20 69 73 20 61 20 66 |olean $b|$ is a f|
|00003510| 75 6e 63 74 69 6f 6e 20 | 77 68 69 63 68 20 72 65 |unction |which re|
|00003520| 73 70 65 63 74 73 20 65 | 71 75 61 6c 69 74 79 2c |spects e|quality,|
|00003530| 0a 73 75 63 68 20 74 68 | 61 74 20 66 6f 72 20 61 |.such th|at for a|
|00003540| 6c 6c 20 24 66 24 2c 20 | 24 67 24 20 61 6e 64 20 |ll $f$, |$g$ and |
|00003550| 24 7a 24 3a 0a 5c 62 65 | 67 69 6e 7b 65 71 6e 61 |$z$:.\be|gin{eqna|
|00003560| 72 72 61 79 2a 7d 0a 20 | 20 20 62 7e 66 7e 67 7e |rray*}. | b~f~g~|
|00003570| 7a 20 20 26 20 20 3d 20 | 20 26 20 20 62 7e 28 66 |z & = | & b~(f|
|00003580| 7e 7a 29 7e 28 67 7e 7a | 29 0a 5c 65 6e 64 7b 65 |~z)~(g~z|).\end{e|
|00003590| 71 6e 61 72 72 61 79 2a | 7d 0a 61 6e 64 20 66 6f |qnarray*|}.and fo|
|000035a0| 72 20 61 6c 6c 20 24 66 | 24 20 61 6e 64 20 24 67 |r all $f|$ and $g|
|000035b0| 24 20 77 68 69 63 68 20 | 72 65 73 70 65 63 74 20 |$ which |respect |
|000035c0| 65 71 75 61 6c 69 74 79 | 2c 0a 5c 62 65 67 69 6e |equality|,.\begin|
|000035d0| 7b 65 71 6e 61 72 72 61 | 79 2a 7d 0a 20 20 20 62 |{eqnarra|y*}. b|
|000035e0| 7e 28 66 7e 62 29 7e 28 | 67 7e 62 29 20 20 26 20 |~(f~b)~(|g~b) & |
|000035f0| 20 3d 20 20 26 20 20 62 | 7e 28 66 7e 46 69 72 73 | = & b|~(f~Firs|
|00003600| 74 29 7e 28 67 7e 53 65 | 63 6f 6e 64 29 0a 5c 65 |t)~(g~Se|cond).\e|
|00003610| 6e 64 7b 65 71 6e 61 72 | 72 61 79 2a 7d 0a 41 6c |nd{eqnar|ray*}.Al|
|00003620| 6c 20 74 68 65 20 66 75 | 6e 63 74 69 6f 6e 73 20 |l the fu|nctions |
|00003630| 69 6e 20 74 68 69 73 20 | 73 65 63 74 69 6f 6e 20 |in this |section |
|00003640| 73 61 74 69 73 66 79 20 | 74 68 65 73 65 20 70 72 |satisfy |these pr|
|00003650| 6f 70 65 72 74 69 65 73 | 2e 20 20 53 75 72 70 72 |operties|. Surpr|
|00003660| 69 73 69 6e 67 6c 79 0a | 65 6e 6f 75 67 68 2c 20 |isingly.|enough, |
|00003670| 73 6f 20 64 6f 65 73 20 | 24 45 72 72 6f 72 24 2c |so does |$Error$,|
|00003680| 20 77 68 69 63 68 20 69 | 73 20 71 75 69 74 65 20 | which i|s quite |
|00003690| 75 73 65 66 75 6c 2c 20 | 61 73 20 69 74 20 61 6c |useful, |as it al|
|000036a0| 6c 6f 77 73 20 75 73 20 | 74 6f 20 0a 72 65 61 73 |lows us |to .reas|
|000036b0| 6f 6e 20 61 62 6f 75 74 | 20 62 6f 6f 6c 65 61 6e |on about| boolean|
|000036c0| 73 20 77 68 69 63 68 20 | 60 60 67 6f 20 77 72 6f |s which |``go wro|
|000036d0| 6e 67 27 27 2e 20 20 0a | 0a 5c 73 75 62 73 65 63 |ng''. .|.\subsec|
|000036e0| 74 69 6f 6e 7b 54 72 75 | 65 2c 20 46 61 6c 73 65 |tion{Tru|e, False|
|000036f0| 20 61 6e 64 20 4e 6f 74 | 7d 0a 0a 53 69 6e 63 65 | and Not|}..Since|
|00003700| 20 77 65 20 61 72 65 20 | 69 6d 70 6c 65 6d 65 6e | we are |implemen|
|00003710| 74 69 6e 67 20 62 6f 6f | 6c 65 61 6e 73 20 61 73 |ting boo|leans as|
|00003720| 20 66 75 6e 63 74 69 6f | 6e 73 2c 20 77 65 20 61 | functio|ns, we a|
|00003730| 6c 72 65 61 64 79 20 68 | 61 76 65 20 74 68 65 0a |lready h|ave the.|
|00003740| 64 65 66 69 6e 69 74 69 | 6f 6e 73 20 6f 66 20 24 |definiti|ons of $|
|00003750| 54 72 75 65 24 2c 20 24 | 46 61 6c 73 65 24 20 61 |True$, $|False$ a|
|00003760| 6e 64 20 24 4e 6f 74 24 | 2e 0a 5c 62 65 67 69 6e |nd $Not$|..\begin|
|00003770| 7b 65 71 6e 61 72 72 61 | 79 2a 7d 0a 20 20 20 20 |{eqnarra|y*}. |
|00003780| 54 72 75 65 20 20 26 20 | 20 3d 20 20 26 20 20 46 |True & | = & F|
|00003790| 69 72 73 74 20 20 5c 5c | 0a 20 20 20 46 61 6c 73 |irst \\|. Fals|
|000037a0| 65 20 20 26 20 20 3d 20 | 20 26 20 20 53 65 63 6f |e & = | & Seco|
|000037b0| 6e 64 20 20 5c 5c 0a 20 | 20 20 20 20 4e 6f 74 20 |nd \\. | Not |
|000037c0| 20 26 20 20 3d 20 20 26 | 20 20 54 77 69 64 64 6c | & = &| Twiddl|
|000037d0| 65 0a 5c 65 6e 64 7b 65 | 71 6e 61 72 72 61 79 2a |e.\end{e|qnarray*|
|000037e0| 7d 0a 53 6f 20 66 6f 72 | 20 66 72 65 65 20 77 65 |}.So for| free we|
|000037f0| 20 67 65 74 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 | get the| followi|
|00003800| 6e 67 20 72 65 73 75 6c | 74 73 3a 0a 5c 62 65 67 |ng resul|ts:.\beg|
|00003810| 69 6e 7b 65 71 6e 61 72 | 72 61 79 2a 7d 0a 20 20 |in{eqnar|ray*}. |
|00003820| 20 20 20 20 20 20 20 20 | 4e 6f 74 7e 54 72 75 65 | |Not~True|
|00003830| 20 20 26 20 20 3d 20 20 | 26 20 20 46 61 6c 73 65 | & = |& False|
|00003840| 20 20 5c 5c 0a 20 20 20 | 20 20 20 20 20 20 4e 6f | \\. | No|
|00003850| 74 7e 46 61 6c 73 65 20 | 20 26 20 20 3d 20 20 26 |t~False | & = &|
|00003860| 20 20 54 72 75 65 20 20 | 5c 5c 0a 20 20 20 43 6f | True |\\. Co|
|00003870| 6d 70 6f 73 65 7e 4e 6f | 74 7e 4e 6f 74 20 20 26 |mpose~No|t~Not &|
|00003880| 20 20 3d 20 20 26 20 20 | 49 64 65 6e 74 69 74 79 | = & |Identity|
|00003890| 20 20 0a 5c 65 6e 64 7b | 65 71 6e 61 72 72 61 79 | .\end{|eqnarray|
|000038a0| 2a 7d 0a 54 68 65 20 5c | 54 65 58 5c 20 69 6d 70 |*}.The \|TeX\ imp|
|000038b0| 6c 65 6d 65 6e 74 61 74 | 69 6f 6e 20 69 73 20 6e |lementat|ion is n|
|000038c0| 6f 74 20 65 78 61 63 74 | 6c 79 20 64 69 66 66 69 |ot exact|ly diffi|
|000038d0| 63 75 6c 74 3a 0a 5c 62 | 65 67 69 6e 7b 54 65 58 |cult:.\b|egin{TeX|
|000038e0| 63 6f 64 65 7d 0a 5c 6c | 65 74 5c 54 72 75 65 3d |code}.\l|et\True=|
|000038f0| 5c 46 69 72 73 74 0a 5c | 6c 65 74 5c 46 61 6c 73 |\First.\|let\Fals|
|00003900| 65 3d 5c 53 65 63 6f 6e | 64 0a 5c 6c 65 74 5c 4e |e=\Secon|d.\let\N|
|00003910| 6f 74 3d 5c 54 77 69 64 | 64 6c 65 0a 5c 65 6e 64 |ot=\Twid|dle.\end|
|00003920| 7b 54 65 58 63 6f 64 65 | 7d 0a 0a 5c 73 75 62 73 |{TeXcode|}..\subs|
|00003930| 65 63 74 69 6f 6e 7b 41 | 6e 64 20 61 6e 64 20 4f |ection{A|nd and O|
|00003940| 72 7d 0a 0a 54 68 65 20 | 64 65 66 69 6e 69 74 69 |r}..The |definiti|
|00003950| 6f 6e 73 20 6f 66 20 24 | 41 6e 64 24 20 61 6e 64 |ons of $|And$ and|
|00003960| 20 24 4f 72 24 20 61 72 | 65 3a 0a 5c 62 65 67 69 | $Or$ ar|e:.\begi|
|00003970| 6e 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 20 20 20 |n{eqnarr|ay*}. |
|00003980| 41 6e 64 7e 61 7e 62 20 | 20 26 20 20 0a 20 20 20 |And~a~b | & . |
|00003990| 3d 20 20 26 20 20 0a 20 | 20 20 5c 6c 65 66 74 5c |= & . | \left\|
|000039a0| 7b 0a 20 20 20 20 20 20 | 5c 62 65 67 69 6e 7b 61 |{. |\begin{a|
|000039b0| 72 72 61 79 7d 7b 6c 6c | 7d 0a 20 20 20 20 20 20 |rray}{ll|}. |
|000039c0| 20 20 20 62 20 20 20 20 | 20 20 26 20 20 5c 6d 62 | b | & \mb|
|000039d0| 6f 78 7b 69 66 20 24 61 | 24 20 69 73 20 74 72 75 |ox{if $a|$ is tru|
|000039e0| 65 7d 20 20 5c 5c 0a 20 | 20 20 20 20 20 20 20 20 |e} \\. | |
|000039f0| 46 61 6c 73 65 20 20 26 | 20 20 5c 6d 62 6f 78 7b |False &| \mbox{|
|00003a00| 6f 74 68 65 72 77 69 73 | 65 7d 0a 20 20 20 20 20 |otherwis|e}. |
|00003a10| 20 5c 65 6e 64 7b 61 72 | 72 61 79 7d 0a 20 20 20 | \end{ar|ray}. |
|00003a20| 5c 72 69 67 68 74 2e 0a | 20 20 20 5c 5c 0a 20 20 |\right..| \\. |
|00003a30| 20 4f 72 7e 61 7e 62 20 | 20 26 20 20 0a 20 20 20 | Or~a~b | & . |
|00003a40| 3d 20 20 26 20 20 0a 20 | 20 20 5c 6c 65 66 74 5c |= & . | \left\|
|00003a50| 7b 0a 20 20 20 20 20 20 | 5c 62 65 67 69 6e 7b 61 |{. |\begin{a|
|00003a60| 72 72 61 79 7d 7b 6c 6c | 7d 0a 20 20 20 20 20 20 |rray}{ll|}. |
|00003a70| 20 20 20 54 72 75 65 20 | 20 20 26 20 20 5c 6d 62 | True | & \mb|
|00003a80| 6f 78 7b 69 66 20 24 61 | 24 20 69 73 20 74 72 75 |ox{if $a|$ is tru|
|00003a90| 65 7d 20 20 5c 5c 0a 20 | 20 20 20 20 20 20 20 20 |e} \\. | |
|00003aa0| 62 20 20 20 20 20 20 26 | 20 20 5c 6d 62 6f 78 7b |b &| \mbox{|
|00003ab0| 6f 74 68 65 72 77 69 73 | 65 7d 0a 20 20 20 20 20 |otherwis|e}. |
|00003ac0| 20 5c 65 6e 64 7b 61 72 | 72 61 79 7d 0a 20 20 20 | \end{ar|ray}. |
|00003ad0| 5c 72 69 67 68 74 2e 0a | 5c 65 6e 64 7b 65 71 6e |\right..|\end{eqn|
|00003ae0| 61 72 72 61 79 2a 7d 0a | 57 69 74 68 20 6f 75 72 |array*}.|With our|
|00003af0| 20 64 65 66 69 6e 69 74 | 69 6f 6e 20 6f 66 20 77 | definit|ion of w|
|00003b00| 68 61 74 20 61 20 62 6f | 6f 6c 65 61 6e 20 69 73 |hat a bo|olean is|
|00003b10| 2c 20 74 68 69 73 20 69 | 73 20 6a 75 73 74 20 74 |, this i|s just t|
|00003b20| 68 65 20 73 61 6d 65 20 | 61 73 0a 5c 62 65 67 69 |he same |as.\begi|
|00003b30| 6e 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 20 20 20 |n{eqnarr|ay*}. |
|00003b40| 41 6e 64 7e 61 7e 62 20 | 20 26 20 20 3d 20 20 26 |And~a~b | & = &|
|00003b50| 20 20 61 7e 62 7e 46 61 | 6c 73 65 20 20 5c 5c 0a | a~b~Fa|lse \\.|
|00003b60| 20 20 20 20 4f 72 7e 61 | 7e 62 20 20 26 20 20 3d | Or~a|~b & =|
|00003b70| 20 20 26 20 20 61 7e 54 | 72 75 65 7e 62 0a 5c 65 | & a~T|rue~b.\e|
|00003b80| 6e 64 7b 65 71 6e 61 72 | 72 61 79 2a 7d 0a 3e 46 |nd{eqnar|ray*}.>F|
|00003b90| 72 6f 6d 20 74 68 65 73 | 65 20 63 6f 6e 64 69 74 |rom thes|e condit|
|00003ba0| 69 6f 6e 73 2c 20 77 65 | 20 63 61 6e 20 73 68 6f |ions, we| can sho|
|00003bb0| 77 20 74 68 61 74 20 24 | 41 6e 64 24 20 69 73 20 |w that $|And$ is |
|00003bc0| 61 73 73 6f 63 69 61 74 | 69 76 65 2c 20 61 6e 64 |associat|ive, and|
|00003bd0| 20 0a 68 61 73 20 6c 65 | 66 74 20 75 6e 69 74 20 | .has le|ft unit |
|00003be0| 24 54 72 75 65 24 20 61 | 6e 64 20 6c 65 66 74 20 |$True$ a|nd left |
|00003bf0| 7a 65 72 6f 73 20 24 46 | 61 6c 73 65 24 20 61 6e |zeros $F|alse$ an|
|00003c00| 64 20 24 45 72 72 6f 72 | 24 3a 0a 5c 62 65 67 69 |d $Error|$:.\begi|
|00003c10| 6e 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 20 20 20 |n{eqnarr|ay*}. |
|00003c20| 41 6e 64 7e 28 41 6e 64 | 7e 61 7e 62 29 7e 63 20 |And~(And|~a~b)~c |
|00003c30| 20 26 20 20 3d 20 20 26 | 20 20 41 6e 64 7e 61 7e | & = &| And~a~|
|00003c40| 28 41 6e 64 7e 62 7e 63 | 29 20 20 5c 5c 0a 20 20 |(And~b~c|) \\. |
|00003c50| 20 20 20 20 20 20 41 6e | 64 7e 54 72 75 65 7e 62 | An|d~True~b|
|00003c60| 20 20 26 20 20 3d 20 20 | 26 20 20 62 20 20 5c 5c | & = |& b \\|
|00003c70| 0a 20 20 20 20 20 20 20 | 41 6e 64 7e 46 61 6c 73 |. |And~Fals|
|00003c80| 65 7e 62 20 20 26 20 20 | 3d 20 20 26 20 20 46 61 |e~b & |= & Fa|
|00003c90| 6c 73 65 20 20 5c 5c 0a | 20 20 20 20 20 20 20 41 |lse \\.| A|
|00003ca0| 6e 64 7e 45 72 72 6f 72 | 7e 62 20 20 26 20 20 3d |nd~Error|~b & =|
|00003cb0| 20 20 26 20 20 45 72 72 | 6f 72 0a 5c 65 6e 64 7b | & Err|or.\end{|
|00003cc0| 65 71 6e 61 72 72 61 79 | 2a 7d 0a 24 4f 72 24 20 |eqnarray|*}.$Or$ |
|00003cd0| 69 73 20 61 73 73 6f 63 | 69 61 74 69 76 65 2c 20 |is assoc|iative, |
|00003ce0| 68 61 73 20 6c 65 66 74 | 20 75 6e 69 74 20 24 46 |has left| unit $F|
|00003cf0| 61 6c 73 65 24 20 61 6e | 64 20 6c 65 66 74 20 7a |alse$ an|d left z|
|00003d00| 65 72 6f 73 20 24 54 72 | 75 65 24 20 61 6e 64 20 |eros $Tr|ue$ and |
|00003d10| 24 45 72 72 6f 72 24 3a | 0a 5c 62 65 67 69 6e 7b |$Error$:|.\begin{|
|00003d20| 65 71 6e 61 72 72 61 79 | 2a 7d 0a 20 20 20 4f 72 |eqnarray|*}. Or|
|00003d30| 7e 28 4f 72 7e 61 7e 62 | 29 7e 63 20 20 26 20 20 |~(Or~a~b|)~c & |
|00003d40| 3d 20 20 26 20 20 4f 72 | 7e 61 7e 28 4f 72 7e 62 |= & Or|~a~(Or~b|
|00003d50| 7e 63 29 20 20 5c 5c 0a | 20 20 20 20 20 20 4f 72 |~c) \\.| Or|
|00003d60| 7e 46 61 6c 73 65 7e 62 | 20 20 26 20 20 3d 20 20 |~False~b| & = |
|00003d70| 26 20 20 62 20 20 5c 5c | 0a 20 20 20 20 20 20 20 |& b \\|. |
|00003d80| 4f 72 7e 54 72 75 65 7e | 62 20 20 26 20 20 3d 20 |Or~True~|b & = |
|00003d90| 20 26 20 20 54 72 75 65 | 20 20 5c 5c 0a 20 20 20 | & True| \\. |
|00003da0| 20 20 20 4f 72 7e 45 72 | 72 6f 72 7e 62 20 20 26 | Or~Er|ror~b &|
|00003db0| 20 20 3d 20 20 26 20 20 | 45 72 72 6f 72 0a 5c 65 | = & |Error.\e|
|00003dc0| 6e 64 7b 65 71 6e 61 72 | 72 61 79 2a 7d 0a 44 65 |nd{eqnar|ray*}.De|
|00003dd0| 7e 4d 6f 72 67 61 6e 27 | 73 20 6c 61 77 73 20 68 |~Morgan'|s laws h|
|00003de0| 6f 6c 64 3a 0a 5c 62 65 | 67 69 6e 7b 65 71 6e 61 |old:.\be|gin{eqna|
|00003df0| 72 72 61 79 2a 7d 0a 20 | 20 20 4e 6f 74 7e 28 41 |rray*}. | Not~(A|
|00003e00| 6e 64 7e 61 7e 62 29 20 | 20 26 20 20 3d 20 20 26 |nd~a~b) | & = &|
|00003e10| 20 20 4f 72 7e 28 4e 6f | 74 7e 61 29 7e 28 4e 6f | Or~(No|t~a)~(No|
|00003e20| 74 7e 62 29 20 20 5c 5c | 0a 20 20 20 20 4e 6f 74 |t~b) \\|. Not|
|00003e30| 7e 28 4f 72 7e 61 7e 62 | 29 20 20 26 20 20 3d 20 |~(Or~a~b|) & = |
|00003e40| 20 26 20 20 41 6e 64 7e | 28 4e 6f 74 7e 61 29 7e | & And~|(Not~a)~|
|00003e50| 28 4e 6f 74 7e 62 29 20 | 20 0a 5c 65 6e 64 7b 65 |(Not~b) | .\end{e|
|00003e60| 71 6e 61 72 72 61 79 2a | 7d 0a 61 6e 64 20 24 41 |qnarray*|}.and $A|
|00003e70| 6e 64 24 20 61 6e 64 20 | 24 4f 72 24 20 6c 65 66 |nd$ and |$Or$ lef|
|00003e80| 74 2d 64 69 73 74 72 69 | 62 75 74 65 20 74 68 72 |t-distri|bute thr|
|00003e90| 6f 75 67 68 20 6f 6e 65 | 20 61 6e 6f 74 68 65 72 |ough one| another|
|00003ea0| 3a 0a 5c 62 65 67 69 6e | 7b 65 71 6e 61 72 72 61 |:.\begin|{eqnarra|
|00003eb0| 79 2a 7d 0a 20 20 20 4f | 72 7e 61 7e 28 41 6e 64 |y*}. O|r~a~(And|
|00003ec0| 7e 62 7e 63 29 20 20 26 | 20 20 3d 20 20 26 20 20 |~b~c) &| = & |
|00003ed0| 41 6e 64 7e 28 4f 72 7e | 61 7e 62 29 7e 28 4f 72 |And~(Or~|a~b)~(Or|
|00003ee0| 7e 61 7e 63 29 20 20 5c | 5c 0a 20 20 20 41 6e 64 |~a~c) \|\. And|
|00003ef0| 7e 61 7e 28 4f 72 7e 62 | 7e 63 29 20 20 26 20 20 |~a~(Or~b|~c) & |
|00003f00| 3d 20 20 26 20 20 4f 72 | 7e 28 41 6e 64 7e 61 7e |= & Or|~(And~a~|
|00003f10| 62 29 7e 28 41 6e 64 7e | 61 7e 63 29 0a 5c 65 6e |b)~(And~|a~c).\en|
|00003f20| 64 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 24 41 6e |d{eqnarr|ay*}.$An|
|00003f30| 64 24 20 61 6e 64 20 24 | 4f 72 24 20 61 72 65 20 |d$ and $|Or$ are |
|00003f40| 7b 5c 65 6d 20 6e 6f 74 | 5c 2f 7d 20 63 6f 6d 6d |{\em not|\/} comm|
|00003f50| 75 74 61 74 69 76 65 2c | 20 74 68 6f 75 67 68 2e |utative,| though.|
|00003f60| 20 20 46 6f 72 20 65 78 | 61 6d 70 6c 65 2c 0a 5c | For ex|ample,.\|
|00003f70| 62 65 67 69 6e 7b 65 71 | 6e 61 72 72 61 79 2a 7d |begin{eq|narray*}|
|00003f80| 0a 20 20 20 5c 73 74 61 | 72 74 7b 4f 72 7e 54 72 |. \sta|rt{Or~Tr|
|00003f90| 75 65 7e 45 72 72 6f 72 | 7d 20 20 0a 20 20 20 26 |ue~Error|} . &|
|00003fa0| 20 20 3d 20 20 26 20 20 | 54 72 75 65 7e 54 72 75 | = & |True~Tru|
|00003fb0| 65 7e 45 72 72 6f 72 20 | 20 5c 5c 0a 20 20 20 26 |e~Error | \\. &|
|00003fc0| 20 20 3d 20 20 26 20 20 | 54 72 75 65 0a 5c 65 6e | = & |True.\en|
|00003fd0| 64 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 62 75 74 |d{eqnarr|ay*}.but|
|00003fe0| 0a 5c 62 65 67 69 6e 7b | 65 71 6e 61 72 72 61 79 |.\begin{|eqnarray|
|00003ff0| 2a 7d 0a 20 20 20 5c 73 | 74 61 72 74 7b 4f 72 7e |*}. \s|tart{Or~|
|00004000| 45 72 72 6f 72 7e 54 72 | 75 65 7d 20 20 0a 20 20 |Error~Tr|ue} . |
|00004010| 20 26 20 20 3d 20 20 26 | 20 20 45 72 72 6f 72 7e | & = &| Error~|
|00004020| 54 72 75 65 7e 54 72 75 | 65 20 5c 5c 0a 20 20 20 |True~Tru|e \\. |
|00004030| 26 20 20 3d 20 20 26 20 | 20 45 72 72 6f 72 0a 5c |& = & | Error.\|
|00004040| 65 6e 64 7b 65 71 6e 61 | 72 72 61 79 2a 7d 0a 54 |end{eqna|rray*}.T|
|00004050| 68 69 73 20 69 73 20 61 | 63 74 75 61 6c 6c 79 20 |his is a|ctually |
|00004060| 71 75 69 74 65 20 75 73 | 65 66 75 6c 20 73 69 6e |quite us|eful sin|
|00004070| 63 65 20 74 68 65 72 65 | 20 61 72 65 20 73 6f 6d |ce there| are som|
|00004080| 65 20 62 6f 6f 6c 65 61 | 6e 73 20 74 68 61 74 0a |e boolea|ns that.|
|00004090| 6e 65 65 64 20 74 6f 20 | 72 65 74 75 72 6e 20 61 |need to |return a|
|000040a0| 6e 20 65 72 72 6f 72 20 | 6f 63 63 61 73 69 6f 6e |n error |occasion|
|000040b0| 61 6c 6c 79 2e 20 20 49 | 66 20 24 61 24 20 69 73 |ally. I|f $a$ is|
|000040c0| 20 24 54 72 75 65 24 20 | 77 68 65 6e 20 24 62 24 | $True$ |when $b$|
|000040d0| 20 0a 69 73 20 73 61 66 | 65 20 28 69 2e 65 2e 5c | .is saf|e (i.e.\|
|000040e0| 20 64 6f 65 73 6e 27 74 | 20 62 65 63 6f 6d 65 20 | doesn't| become |
|000040f0| 24 45 72 72 6f 72 24 29 | 20 61 6e 64 20 69 73 20 |$Error$)| and is |
|00004100| 24 46 61 6c 73 65 24 20 | 6f 74 68 65 72 77 69 73 |$False$ |otherwis|
|00004110| 65 2c 20 77 65 20 63 61 | 6e 0a 73 61 79 20 24 4f |e, we ca|n.say $O|
|00004120| 72 7e 61 7e 62 24 20 61 | 6e 64 20 6b 6e 6f 77 20 |r~a~b$ a|nd know |
|00004130| 77 65 27 72 65 20 6e 6f | 74 20 67 6f 69 6e 67 20 |we're no|t going |
|00004140| 74 6f 20 67 65 74 20 61 | 6e 20 65 72 72 6f 72 2e |to get a|n error.|
|00004150| 20 20 54 68 69 73 20 69 | 73 20 68 61 6e 64 79 0a | This i|s handy.|
|00004160| 66 6f 72 20 74 68 69 6e | 67 73 20 6c 69 6b 65 20 |for thin|gs like |
|00004170| 63 68 65 63 6b 69 6e 67 | 20 66 6f 72 20 64 69 76 |checking| for div|
|00004180| 69 73 69 6f 6e 20 62 79 | 20 7a 65 72 6f 2c 20 6f |ision by| zero, o|
|00004190| 72 20 74 72 79 69 6e 67 | 20 74 6f 20 67 65 74 20 |r trying| to get |
|000041a0| 74 68 65 0a 66 69 72 73 | 74 20 65 6c 65 6d 65 6e |the.firs|t elemen|
|000041b0| 74 20 6f 66 20 61 6e 20 | 65 6d 70 74 79 20 6c 69 |t of an |empty li|
|000041c0| 73 74 2e 0a 0a 53 69 6d | 69 6c 61 72 6c 79 2c 20 |st...Sim|ilarly, |
|000041d0| 62 65 63 61 75 73 65 20 | 6f 66 20 74 68 65 20 70 |because |of the p|
|000041e0| 6f 73 73 69 62 69 6c 69 | 74 79 20 6f 66 20 24 45 |ossibili|ty of $E|
|000041f0| 72 72 6f 72 24 2c 0a 24 | 41 6e 64 24 20 61 6e 64 |rror$,.$|And$ and|
|00004200| 20 24 4f 72 24 20 64 6f | 6e 27 74 20 72 69 67 68 | $Or$ do|n't righ|
|00004210| 74 2d 64 69 73 74 72 69 | 62 75 74 65 20 74 68 72 |t-distri|bute thr|
|00004220| 6f 75 67 68 20 65 61 63 | 68 20 6f 74 68 65 72 2c |ough eac|h other,|
|00004230| 0a 61 73 0a 5c 62 65 67 | 69 6e 7b 65 71 6e 61 72 |.as.\beg|in{eqnar|
|00004240| 72 61 79 2a 7d 0a 20 20 | 20 5c 73 74 61 72 74 7b |ray*}. | \start{|
|00004250| 4f 72 7e 28 41 6e 64 7e | 46 61 6c 73 65 7e 45 72 |Or~(And~|False~Er|
|00004260| 72 6f 72 29 7e 54 72 75 | 65 7d 0a 20 20 20 26 20 |ror)~Tru|e}. & |
|00004270| 20 5c 6e 65 20 20 26 20 | 20 41 6e 64 7e 28 4f 72 | \ne & | And~(Or|
|00004280| 7e 46 61 6c 73 65 7e 54 | 72 75 65 29 7e 28 4f 72 |~False~T|rue)~(Or|
|00004290| 7e 45 72 72 6f 72 7e 54 | 72 75 65 29 0a 5c 65 6e |~Error~T|rue).\en|
|000042a0| 64 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 41 73 20 |d{eqnarr|ay*}.As |
|000042b0| 65 72 72 6f 72 73 20 73 | 68 6f 75 6c 64 6e 27 74 |errors s|houldn't|
|000042c0| 20 63 72 6f 70 20 75 70 | 2c 20 74 68 69 73 20 6e | crop up|, this n|
|000042d0| 65 65 64 6e 27 74 20 77 | 6f 72 72 79 20 75 73 20 |eedn't w|orry us |
|000042e0| 74 6f 6f 20 6d 75 63 68 | 2e 0a 5c 62 65 67 69 6e |too much|..\begin|
|000042f0| 7b 54 65 58 63 6f 64 65 | 7d 0a 5c 64 65 66 5c 41 |{TeXcode|}.\def\A|
|00004300| 6e 64 23 31 23 32 7b 23 | 31 7b 23 32 7d 5c 46 61 |nd#1#2{#|1{#2}\Fa|
|00004310| 6c 73 65 7d 0a 5c 64 65 | 66 5c 4f 72 23 31 23 32 |lse}.\de|f\Or#1#2|
|00004320| 7b 23 31 5c 54 72 75 65 | 7b 23 32 7d 7d 0a 5c 65 |{#1\True|{#2}}.\e|
|00004330| 6e 64 7b 54 65 58 63 6f | 64 65 7d 0a 0a 5c 73 75 |nd{TeXco|de}..\su|
|00004340| 62 73 65 63 74 69 6f 6e | 7b 4c 69 66 74 7d 0a 0a |bsection|{Lift}..|
|00004350| 51 75 69 74 65 20 61 20 | 6c 6f 74 20 6f 66 20 74 |Quite a |lot of t|
|00004360| 68 65 20 74 69 6d 65 20 | 77 65 20 77 6f 6e 27 74 |he time |we won't|
|00004370| 20 62 65 20 64 65 61 6c | 69 6e 67 20 77 69 74 68 | be deal|ing with|
|00004380| 20 62 6f 6f 6c 65 61 6e | 73 2c 20 62 75 74 20 77 | boolean|s, but w|
|00004390| 69 74 68 0a 7b 5c 65 6d | 20 70 72 65 64 69 63 61 |ith.{\em| predica|
|000043a0| 74 65 73 7d 2c 20 77 68 | 69 63 68 20 61 72 65 20 |tes}, wh|ich are |
|000043b0| 6a 75 73 74 20 66 75 6e | 63 74 69 6f 6e 73 20 74 |just fun|ctions t|
|000043c0| 68 61 74 20 72 65 74 75 | 72 6e 20 61 20 62 6f 6f |hat retu|rn a boo|
|000043d0| 6c 65 61 6e 2e 0a 46 6f | 72 20 65 78 61 6d 70 6c |lean..Fo|r exampl|
|000043e0| 65 2c 20 74 68 65 20 70 | 72 65 64 69 63 61 74 65 |e, the p|redicate|
|000043f0| 20 24 4c 65 73 73 74 68 | 61 6e 24 20 69 73 20 64 | $Lessth|an$ is d|
|00004400| 65 66 69 6e 65 64 20 62 | 65 6c 6f 77 20 73 6f 20 |efined b|elow so |
|00004410| 74 68 61 74 0a 24 4c 65 | 73 73 74 68 61 6e 7e 69 |that.$Le|ssthan~i|
|00004420| 7e 6a 24 20 69 73 20 74 | 72 75 65 20 77 68 65 6e |~j$ is t|rue when|
|00004430| 65 76 65 72 20 24 69 3c | 6a 24 2e 0a 47 69 76 65 |ever $i<|j$..Give|
|00004440| 6e 20 61 20 70 72 65 64 | 69 63 61 74 65 20 24 70 |n a pred|icate $p|
|00004450| 24 20 77 65 20 77 6f 75 | 6c 64 20 6c 69 6b 65 20 |$ we wou|ld like |
|00004460| 74 6f 20 62 65 20 61 62 | 6c 65 20 74 6f 20 0a 7b |to be ab|le to .{|
|00004470| 5c 65 6d 20 6c 69 66 74 | 5c 2f 7d 20 69 74 20 74 |\em lift|\/} it t|
|00004480| 6f 20 24 4c 69 66 74 7e | 70 24 2c 20 64 65 66 69 |o $Lift~|p$, defi|
|00004490| 6e 65 64 3a 0a 5c 62 65 | 67 69 6e 7b 65 71 6e 61 |ned:.\be|gin{eqna|
|000044a0| 72 72 61 79 2a 7d 0a 20 | 20 20 4c 69 66 74 7e 70 |rray*}. | Lift~p|
|000044b0| 7e 66 7e 67 7e 78 20 20 | 26 20 20 3d 20 20 26 20 |~f~g~x |& = & |
|000044c0| 20 70 7e 78 7e 66 7e 67 | 7e 78 0a 5c 65 6e 64 7b | p~x~f~g|~x.\end{|
|000044d0| 65 71 6e 61 72 72 61 79 | 2a 7d 0a 46 6f 72 20 65 |eqnarray|*}.For e|
|000044e0| 78 61 6d 70 6c 65 2c 20 | 24 4c 69 66 74 7e 28 4c |xample, |$Lift~(L|
|000044f0| 65 73 73 74 68 61 6e 7e | 30 29 7e 66 7e 67 24 20 |essthan~|0)~f~g$ |
|00004500| 74 61 6b 65 73 20 69 6e | 20 61 20 6e 75 6d 62 65 |takes in| a numbe|
|00004510| 72 20 61 6e 64 20 61 70 | 70 6c 69 65 73 0a 24 66 |r and ap|plies.$f|
|00004520| 24 20 74 6f 20 69 74 20 | 69 66 20 69 74 20 69 73 |$ to it |if it is|
|00004530| 20 70 6f 73 69 74 69 76 | 65 20 61 6e 64 20 24 67 | positiv|e and $g|
|00004540| 24 20 74 6f 20 69 74 20 | 6f 74 68 65 72 77 69 73 |$ to it |otherwis|
|00004550| 65 2e 20 20 54 68 69 73 | 20 69 73 20 71 75 69 74 |e. This| is quit|
|00004560| 65 0a 75 73 65 66 75 6c | 20 66 6f 72 20 64 65 66 |e.useful| for def|
|00004570| 69 6e 69 6e 67 20 66 75 | 6e 63 74 69 6f 6e 73 2e |ining fu|nctions.|
|00004580| 0a 5c 62 65 67 69 6e 7b | 54 65 58 63 6f 64 65 7d |.\begin{|TeXcode}|
|00004590| 0a 5c 64 65 66 5c 4c 69 | 66 74 23 31 23 32 23 33 |.\def\Li|ft#1#2#3|
|000045a0| 23 34 7b 23 31 7b 23 34 | 7d 7b 23 32 7d 7b 23 33 |#4{#1{#4|}{#2}{#3|
|000045b0| 7d 7b 23 34 7d 7d 0a 5c | 65 6e 64 7b 54 65 58 63 |}{#4}}.\|end{TeXc|
|000045c0| 6f 64 65 7d 0a 0a 5c 73 | 75 62 73 65 63 74 69 6f |ode}..\s|ubsectio|
|000045d0| 6e 7b 4c 65 73 73 74 68 | 61 6e 20 61 6e 64 20 5c |n{Lessth|an and \|
|000045e0| 54 65 58 20 69 66 7d 0a | 0a 46 69 6e 61 6c 6c 79 |TeX if}.|.Finally|
|000045f0| 2c 20 77 65 20 77 6f 75 | 6c 64 20 6c 69 6b 65 20 |, we wou|ld like |
|00004600| 74 6f 20 62 65 20 61 62 | 6c 65 20 74 6f 20 75 73 |to be ab|le to us|
|00004610| 65 20 5c 54 65 58 27 73 | 20 62 75 69 6c 74 2d 69 |e \TeX's| built-i|
|00004620| 6e 20 62 6f 6f 6c 65 61 | 6e 73 0a 61 73 20 77 65 |n boolea|ns.as we|
|00004630| 6c 6c 20 61 73 20 6f 75 | 72 20 6f 77 6e 2e 20 20 |ll as ou|r own. |
|00004640| 46 6f 72 20 65 78 61 6d | 70 6c 65 2c 20 77 65 20 |For exam|ple, we |
|00004650| 77 6f 75 6c 64 20 6c 69 | 6b 65 20 61 20 70 72 65 |would li|ke a pre|
|00004660| 64 69 63 61 74 65 0a 24 | 4c 65 73 73 74 68 61 6e |dicate.$|Lessthan|
|00004670| 24 20 73 75 63 68 20 74 | 68 61 74 3a 0a 5c 62 65 |$ such t|hat:.\be|
|00004680| 67 69 6e 7b 65 71 6e 61 | 72 72 61 79 2a 7d 0a 20 |gin{eqna|rray*}. |
|00004690| 20 20 4c 65 73 73 74 68 | 61 6e 7e 69 7e 6a 20 20 | Lessth|an~i~j |
|000046a0| 26 20 20 0a 20 20 20 3d | 20 20 26 0a 20 20 20 5c |& . =| &. \|
|000046b0| 6c 65 66 74 5c 7b 0a 20 | 20 20 20 20 20 5c 62 65 |left\{. | \be|
|000046c0| 67 69 6e 7b 61 72 72 61 | 79 7d 7b 6c 6c 7d 0a 20 |gin{arra|y}{ll}. |
|000046d0| 20 20 20 20 20 20 20 20 | 54 72 75 65 20 20 20 26 | |True &|
|000046e0| 20 20 5c 6d 62 6f 78 7b | 69 66 20 7d 20 69 20 3c | \mbox{|if } i <|
|000046f0| 20 6a 20 20 20 20 5c 5c | 0a 20 20 20 20 20 20 20 | j \\|. |
|00004700| 20 20 46 61 6c 73 65 20 | 20 26 20 20 5c 6d 62 6f | False | & \mbo|
|00004710| 78 7b 69 66 20 7d 20 69 | 20 5c 67 65 20 6a 20 20 |x{if } i| \ge j |
|00004720| 5c 5c 0a 20 20 20 20 20 | 20 20 20 20 45 72 72 6f |\\. | Erro|
|00004730| 72 20 20 26 20 20 5c 6d | 62 6f 78 7b 6f 74 68 65 |r & \m|box{othe|
|00004740| 72 77 69 73 65 7d 20 20 | 0a 20 20 20 20 20 20 5c |rwise} |. \|
|00004750| 65 6e 64 7b 61 72 72 61 | 79 7d 0a 20 20 20 5c 72 |end{arra|y}. \r|
|00004760| 69 67 68 74 2e 0a 5c 65 | 6e 64 7b 65 71 6e 61 72 |ight..\e|nd{eqnar|
|00004770| 72 61 79 2a 7d 0a 54 68 | 65 20 24 45 72 72 6f 72 |ray*}.Th|e $Error|
|00004780| 24 20 63 6f 6e 64 69 74 | 69 6f 6e 20 68 61 70 70 |$ condit|ion happ|
|00004790| 65 6e 73 20 69 66 20 77 | 65 20 74 72 79 20 61 70 |ens if w|e try ap|
|000047a0| 70 6c 79 69 6e 67 20 24 | 4c 65 73 73 74 68 61 6e |plying $|Lessthan|
|000047b0| 24 20 74 6f 20 73 6f 6d | 65 74 68 69 6e 67 0a 74 |$ to som|ething.t|
|000047c0| 68 61 74 20 69 73 6e 27 | 74 20 61 20 6e 75 6d 62 |hat isn'|t a numb|
|000047d0| 65 72 20 2d 2d 2d 20 24 | 4c 65 73 73 74 68 61 6e |er --- $|Lessthan|
|000047e0| 7e 54 72 75 65 7e 46 61 | 6c 73 65 24 20 69 73 20 |~True~Fa|lse$ is |
|000047f0| 24 45 72 72 6f 72 24 25 | 0a 5c 66 6f 6f 74 6e 6f |$Error$%|.\footno|
|00004800| 74 65 0a 20 20 20 7b 41 | 63 74 75 61 6c 6c 79 2c |te. {A|ctually,|
|00004810| 20 74 68 61 74 27 73 20 | 61 20 6c 69 74 74 6c 65 | that's |a little|
|00004820| 20 77 68 69 74 65 20 6c | 69 65 20 2d 2d 2d 20 74 | white l|ie --- t|
|00004830| 72 79 69 6e 67 20 74 6f | 20 70 65 72 73 75 61 64 |rying to| persuad|
|00004840| 65 20 5c 54 65 58 5c 20 | 74 6f 0a 20 20 20 20 64 |e \TeX\ |to. d|
|00004850| 6f 20 72 75 6e 2d 74 69 | 6d 65 20 74 79 70 65 20 |o run-ti|me type |
|00004860| 63 68 65 63 6b 69 6e 67 | 20 69 73 6e 27 74 20 6d |checking| isn't m|
|00004870| 75 63 68 20 66 75 6e 2e | 20 20 53 6f 20 74 68 65 |uch fun.| So the|
|00004880| 20 5c 54 65 58 5c 20 69 | 6d 70 6c 65 6d 65 6e 74 | \TeX\ i|mplement|
|00004890| 61 74 69 6f 6e 0a 20 20 | 20 20 6f 66 20 74 68 69 |ation. | of thi|
|000048a0| 73 20 69 73 20 61 63 74 | 75 61 6c 6c 79 20 61 20 |s is act|ually a |
|000048b0| 7b 5c 65 6d 20 72 65 66 | 69 6e 65 6d 65 6e 74 5c |{\em ref|inement\|
|000048c0| 2f 7d 20 77 68 65 72 65 | 20 74 68 65 20 24 45 72 |/} where| the $Er|
|000048d0| 72 6f 72 24 20 63 6f 6e | 64 69 74 69 6f 6e 0a 20 |ror$ con|dition. |
|000048e0| 20 20 20 68 61 73 20 62 | 65 65 6e 20 72 65 70 6c | has b|een repl|
|000048f0| 61 63 65 64 20 62 79 20 | 77 68 61 74 65 76 65 72 |aced by |whatever|
|00004900| 20 69 74 20 69 73 20 5c | 54 65 58 5c 20 64 6f 65 | it is \|TeX\ doe|
|00004910| 73 20 69 66 20 79 6f 75 | 20 74 72 79 20 64 6f 69 |s if you| try doi|
|00004920| 6e 67 0a 20 20 20 20 7b | 5c 74 74 5c 73 74 72 69 |ng. {|\tt\stri|
|00004930| 6e 67 5c 69 66 6e 75 6d | 20 24 78 24 20 3c 20 24 |ng\ifnum| $x$ < $|
|00004940| 79 24 7d 20 77 68 65 6e | 20 24 78 24 20 61 6e 64 |y$} when| $x$ and|
|00004950| 20 24 79 24 20 61 72 65 | 6e 27 74 20 6e 75 6d 62 | $y$ are|n't numb|
|00004960| 65 72 73 7d 2e 0a 54 68 | 69 73 20 69 73 20 66 69 |ers}..Th|is is fi|
|00004970| 6e 65 20 61 73 20 61 20 | 6d 61 74 68 65 6d 61 74 |ne as a |mathemat|
|00004980| 69 63 61 6c 20 64 65 66 | 69 6e 69 74 69 6f 6e 2c |ical def|inition,|
|00004990| 20 62 75 74 20 68 6f 77 | 20 77 69 6c 6c 0a 77 65 | but how| will.we|
|000049a0| 20 69 6d 70 6c 65 6d 65 | 6e 74 20 69 74 3f 20 20 | impleme|nt it? |
|000049b0| 49 66 20 77 65 20 61 73 | 73 75 6d 65 20 77 65 20 |If we as|sume we |
|000049c0| 68 61 76 65 20 61 20 6d | 61 63 72 6f 20 5c 76 65 |have a m|acro \ve|
|000049d0| 72 62 7c 5c 54 65 58 69 | 66 7c 2c 0a 77 68 69 63 |rb|\TeXi|f|,.whic|
|000049e0| 68 20 63 6f 6e 76 65 72 | 74 73 20 5c 54 65 58 5c |h conver|ts \TeX\|
|000049f0| 20 69 66 2d 73 74 61 74 | 65 6d 65 6e 74 73 20 69 | if-stat|ements i|
|00004a00| 6e 74 6f 20 62 6f 6f 6c | 65 61 6e 73 2c 20 77 65 |nto bool|eans, we|
|00004a10| 20 63 6f 75 6c 64 20 6a | 75 73 74 0a 64 65 66 69 | could j|ust.defi|
|00004a20| 6e 65 3a 0a 5c 62 65 67 | 69 6e 7b 54 65 58 63 6f |ne:.\beg|in{TeXco|
|00004a30| 64 65 7d 0a 5c 64 65 66 | 5c 4c 65 73 73 74 68 61 |de}.\def|\Lesstha|
|00004a40| 6e 23 31 23 32 7b 5c 54 | 65 58 69 66 7b 5c 69 66 |n#1#2{\T|eXif{\if|
|00004a50| 6e 75 6d 23 31 3c 23 32 | 20 7d 7d 0a 5c 65 6e 64 |num#1<#2| }}.\end|
|00004a60| 7b 54 65 58 63 6f 64 65 | 7d 0a 53 6f 20 74 68 65 |{TeXcode|}.So the|
|00004a70| 20 71 75 65 73 74 69 6f | 6e 20 69 73 20 6a 75 73 | questio|n is jus|
|00004a80| 74 20 68 6f 77 20 74 6f | 20 64 65 66 69 6e 65 20 |t how to| define |
|00004a90| 5c 76 65 72 62 7c 5c 54 | 65 58 69 66 7c 2e 0a 55 |\verb|\T|eXif|..U|
|00004aa0| 6e 66 6f 72 74 75 6e 61 | 74 65 6c 79 2c 20 74 68 |nfortuna|tely, th|
|00004ab0| 65 20 60 60 6f 62 76 69 | 6f 75 73 27 27 20 63 6f |e ``obvi|ous'' co|
|00004ac0| 64 65 20 64 6f 65 73 20 | 6e 6f 74 20 77 6f 72 6b |de does |not work|
|00004ad0| 3a 0a 5c 62 65 67 69 6e | 7b 76 65 72 62 61 74 69 |:.\begin|{verbati|
|00004ae0| 6d 7d 0a 5c 64 65 66 5c | 54 65 58 69 66 23 31 23 |m}.\def\|TeXif#1#|
|00004af0| 32 23 33 7b 23 31 23 32 | 5c 65 6c 73 65 23 33 5c |2#3{#1#2|\else#3\|
|00004b00| 66 69 7d 0a 5c 65 6e 64 | 7b 76 65 72 62 61 74 69 |fi}.\end|{verbati|
|00004b10| 6d 7d 0a 46 6f 72 20 65 | 78 61 6d 70 6c 65 2c 20 |m}.For e|xample, |
|00004b20| 5c 76 65 72 62 7c 5c 54 | 65 58 69 66 5c 69 66 74 |\verb|\T|eXif\ift|
|00004b30| 72 75 65 5c 54 72 75 65 | 5c 54 72 75 65 7c 20 64 |rue\True|\True| d|
|00004b40| 6f 65 73 6e 27 74 20 65 | 78 70 61 6e 64 20 6f 75 |oesn't e|xpand ou|
|00004b50| 74 20 74 6f 0a 5c 76 65 | 72 62 7c 5c 54 72 75 65 |t to.\ve|rb|\True|
|00004b60| 7c 2e 20 20 49 6e 73 74 | 65 61 64 2c 20 69 74 20 ||. Inst|ead, it |
|00004b70| 65 78 70 61 6e 64 73 20 | 61 73 3a 0a 5c 62 65 67 |expands |as:.\beg|
|00004b80| 69 6e 7b 76 65 72 62 61 | 74 69 6d 7d 0a 5c 54 65 |in{verba|tim}.\Te|
|00004b90| 58 69 66 5c 69 66 74 72 | 75 65 5c 54 72 75 65 5c |Xif\iftr|ue\True\|
|00004ba0| 54 72 75 65 0a 20 20 20 | 3d 20 5c 69 66 74 72 75 |True. |= \iftru|
|00004bb0| 65 5c 54 72 75 65 5c 65 | 6c 73 65 5c 54 72 75 65 |e\True\e|lse\True|
|00004bc0| 5c 66 69 0a 20 20 20 3d | 20 5c 54 72 75 65 5c 65 |\fi. =| \True\e|
|00004bd0| 6c 73 65 5c 54 72 75 65 | 5c 66 69 0a 20 20 20 3d |lse\True|\fi. =|
|00004be0| 20 5c 65 6c 73 65 5c 66 | 69 0a 20 20 20 3d 0a 5c | \else\f|i. =.\|
|00004bf0| 65 6e 64 7b 76 65 72 62 | 61 74 69 6d 7d 0a 41 6e |end{verb|atim}.An|
|00004c00| 6f 74 68 65 72 20 63 6f | 6d 6d 6f 6e 20 5c 54 65 |other co|mmon \Te|
|00004c10| 58 20 6e 69 71 75 65 20 | 69 73 20 74 6f 20 75 73 |X nique |is to us|
|00004c20| 65 20 61 20 6d 61 63 72 | 6f 20 5c 76 65 72 62 7c |e a macr|o \verb||
|00004c30| 5c 6e 65 78 74 7c 20 74 | 6f 0a 62 65 20 74 68 65 |\next| t|o.be the|
|00004c40| 20 65 78 70 61 6e 73 69 | 6f 6e 20 74 65 78 74 3a | expansi|on text:|
|00004c50| 0a 5c 62 65 67 69 6e 7b | 76 65 72 62 61 74 69 6d |.\begin{|verbatim|
|00004c60| 7d 0a 5c 64 65 66 5c 54 | 65 58 69 66 23 31 23 32 |}.\def\T|eXif#1#2|
|00004c70| 23 33 25 0a 20 20 20 7b | 23 31 5c 64 65 66 5c 6e |#3%. {|#1\def\n|
|00004c80| 65 78 74 7b 23 32 7d 5c | 65 6c 73 65 5c 64 65 66 |ext{#2}\|else\def|
|00004c90| 5c 6e 65 78 74 7b 23 33 | 7d 5c 66 69 0a 20 20 20 |\next{#3|}\fi. |
|00004ca0| 20 5c 6e 65 78 74 7d 0a | 5c 65 6e 64 7b 76 65 72 | \next}.|\end{ver|
|00004cb0| 62 61 74 69 6d 7d 0a 48 | 6f 77 65 76 65 72 2c 20 |batim}.H|owever, |
|00004cc0| 74 68 69 73 20 75 73 65 | 73 20 5c 54 65 58 27 73 |this use|s \TeX's|
|00004cd0| 20 73 74 6f 6d 61 63 68 | 20 74 6f 20 64 6f 20 74 | stomach| to do t|
|00004ce0| 68 65 20 5c 76 65 72 62 | 7c 5c 64 65 66 7c 2c 20 |he \verb||\def|, |
|00004cf0| 61 6e 64 20 77 65 20 61 | 72 65 0a 74 72 79 69 6e |and we a|re.tryin|
|00004d00| 67 20 74 6f 20 64 6f 20 | 74 68 69 73 20 75 73 69 |g to do |this usi|
|00004d10| 6e 67 20 6f 6e 6c 79 20 | 74 68 65 20 6d 6f 75 74 |ng only |the mout|
|00004d20| 68 2e 20 20 4f 6e 65 20 | 28 73 6c 69 67 68 74 6c |h. One |(slightl|
|00004d30| 79 20 74 72 69 63 6b 79 | 29 20 73 6f 6c 75 74 69 |y tricky|) soluti|
|00004d40| 6f 6e 0a 69 73 20 74 6f | 20 75 73 65 20 70 61 74 |on.is to| use pat|
|00004d50| 74 65 72 6e 2d 6d 61 74 | 63 68 69 6e 67 20 74 6f |tern-mat|ching to|
|00004d60| 20 67 6f 62 62 6c 65 20 | 75 70 20 74 68 65 20 6f | gobble |up the o|
|00004d70| 66 66 65 6e 64 69 6e 67 | 20 5c 76 65 72 62 7c 5c |ffending| \verb|\|
|00004d80| 65 6c 73 65 7c 20 61 6e | 64 2f 6f 72 0a 5c 76 65 |else| an|d/or.\ve|
|00004d90| 72 62 7c 5c 66 69 7c 2e | 0a 5c 62 65 67 69 6e 7b |rb|\fi|.|.\begin{|
|00004da0| 54 65 58 63 6f 64 65 7d | 0a 5c 64 65 66 5c 67 6f |TeXcode}|.\def\go|
|00004db0| 62 62 6c 65 66 61 6c 73 | 65 5c 65 6c 73 65 5c 67 |bblefals|e\else\g|
|00004dc0| 6f 62 62 6c 65 74 72 75 | 65 5c 66 69 23 31 23 32 |obbletru|e\fi#1#2|
|00004dd0| 25 0a 20 20 20 7b 5c 66 | 69 23 31 7d 0a 5c 64 65 |%. {\f|i#1}.\de|
|00004de0| 66 5c 67 6f 62 62 6c 65 | 74 72 75 65 5c 66 69 23 |f\gobble|true\fi#|
|00004df0| 31 23 32 25 0a 20 20 20 | 7b 5c 66 69 23 32 7d 0a |1#2%. |{\fi#2}.|
|00004e00| 5c 64 65 66 5c 54 65 58 | 69 66 23 31 25 0a 20 20 |\def\TeX|if#1%. |
|00004e10| 20 7b 23 31 5c 67 6f 62 | 62 6c 65 66 61 6c 73 65 | {#1\gob|blefalse|
|00004e20| 5c 65 6c 73 65 5c 67 6f | 62 62 6c 65 74 72 75 65 |\else\go|bbletrue|
|00004e30| 5c 66 69 7d 0a 5c 65 6e | 64 7b 54 65 58 63 6f 64 |\fi}.\en|d{TeXcod|
|00004e40| 65 7d 0a 53 6f 20 69 66 | 20 74 68 65 20 5c 54 65 |e}.So if| the \Te|
|00004e50| 58 5c 20 69 66 2d 73 74 | 61 74 65 6d 65 6e 74 20 |X\ if-st|atement |
|00004e60| 69 73 20 74 72 75 65 2c | 20 5c 76 65 72 62 7c 5c |is true,| \verb|\|
|00004e70| 67 6f 62 62 6c 65 66 61 | 6c 73 65 7c 20 67 6f 62 |gobblefa|lse| gob|
|00004e80| 62 6c 65 73 0a 75 70 20 | 74 68 65 20 66 61 6c 73 |bles.up |the fals|
|00004e90| 65 2d 74 65 78 74 2c 20 | 6f 74 68 65 72 77 69 73 |e-text, |otherwis|
|00004ea0| 65 20 5c 76 65 72 62 7c | 5c 67 6f 62 62 6c 65 74 |e \verb||\gobblet|
|00004eb0| 72 75 65 7c 20 67 6f 62 | 62 6c 65 73 20 75 70 20 |rue| gob|bles up |
|00004ec0| 74 68 65 20 0a 74 72 75 | 65 2d 74 65 78 74 2e 20 |the .tru|e-text. |
|00004ed0| 20 46 6f 72 20 65 78 61 | 6d 70 6c 65 2c 0a 5c 62 | For exa|mple,.\b|
|00004ee0| 65 67 69 6e 7b 76 65 72 | 62 61 74 69 6d 7d 0a 5c |egin{ver|batim}.\|
|00004ef0| 54 65 58 69 66 5c 69 66 | 74 72 75 65 5c 54 72 75 |TeXif\if|true\Tru|
|00004f00| 65 5c 54 72 75 65 0a 20 | 20 20 3d 20 5c 69 66 74 |e\True. | = \ift|
|00004f10| 72 75 65 5c 67 6f 62 62 | 6c 65 66 61 6c 73 65 5c |rue\gobb|lefalse\|
|00004f20| 65 6c 73 65 0a 20 20 20 | 20 20 20 20 20 20 5c 67 |else. | \g|
|00004f30| 6f 62 62 6c 65 74 72 75 | 65 5c 66 69 5c 54 72 75 |obbletru|e\fi\Tru|
|00004f40| 65 5c 54 72 75 65 0a 20 | 20 20 3d 20 5c 67 6f 62 |e\True. | = \gob|
|00004f50| 62 6c 65 66 61 6c 73 65 | 5c 65 6c 73 65 0a 20 20 |blefalse|\else. |
|00004f60| 20 20 20 20 20 20 20 5c | 67 6f 62 62 6c 65 74 72 | \|gobbletr|
|00004f70| 75 65 5c 66 69 5c 54 72 | 75 65 5c 54 72 75 65 0a |ue\fi\Tr|ue\True.|
|00004f80| 20 20 20 3d 20 5c 66 69 | 5c 54 72 75 65 0a 20 20 | = \fi|\True. |
|00004f90| 20 3d 20 5c 54 72 75 65 | 0a 5c 65 6e 64 7b 76 65 | = \True|.\end{ve|
|00004fa0| 72 62 61 74 69 6d 7d 0a | 50 68 65 77 2e 20 20 41 |rbatim}.|Phew. A|
|00004fb0| 6e 64 20 73 6f 20 77 65 | 20 68 61 76 65 20 62 6f |nd so we| have bo|
|00004fc0| 6f 6c 65 61 6e 73 2e 0a | 0a 5c 73 65 63 74 69 6f |oleans..|.\sectio|
|00004fd0| 6e 7b 4c 69 73 74 73 7d | 0a 0a 41 20 6c 69 73 74 |n{Lists}|..A list|
|00004fe0| 20 69 73 20 61 20 28 70 | 6f 73 73 69 62 6c 79 20 | is a (p|ossibly |
|00004ff0| 69 6e 66 69 6e 69 74 65 | 29 20 73 65 71 75 65 6e |infinite|) sequen|
|00005000| 63 65 20 6f 66 20 76 61 | 6c 75 65 73 2e 20 20 46 |ce of va|lues. F|
|00005010| 6f 72 20 65 78 61 6d 70 | 6c 65 2c 0a 74 68 65 20 |or examp|le,.the |
|00005020| 6c 69 73 74 20 24 5b 31 | 2c 32 2c 33 5d 24 20 63 |list $[1|,2,3]$ c|
|00005030| 6f 6e 74 61 69 6e 73 20 | 74 68 72 65 65 20 6e 75 |ontains |three nu|
|00005040| 6d 62 65 72 73 2c 20 74 | 68 65 20 6c 69 73 74 20 |mbers, t|he list |
|00005050| 24 5c 6e 69 6c 24 20 63 | 6f 6e 74 61 69 6e 73 0a |$\nil$ c|ontains.|
|00005060| 6e 6f 6e 65 2c 20 61 6e | 64 20 74 68 65 20 6c 69 |none, an|d the li|
|00005070| 73 74 20 24 5b 31 2c 32 | 2c 33 2c 5c 6c 64 6f 74 |st $[1,2|,3,\ldot|
|00005080| 73 5d 24 20 63 6f 6e 74 | 61 69 6e 73 20 69 6e 66 |s]$ cont|ains inf|
|00005090| 69 6e 69 74 65 6c 79 20 | 6d 61 6e 79 2e 0a 41 20 |initely |many..A |
|000050a0| 6c 69 73 74 20 69 73 20 | 65 69 74 68 65 72 20 7b |list is |either {|
|000050b0| 5c 65 6d 20 65 6d 70 74 | 79 5c 2f 7d 20 28 77 72 |\em empt|y\/} (wr|
|000050c0| 69 74 74 65 6e 20 24 5c | 6e 69 6c 24 29 20 6f 72 |itten $\|nil$) or|
|000050d0| 20 69 73 20 63 6f 6d 70 | 72 69 73 65 64 0a 6f 66 | is comp|rised.of|
|000050e0| 20 61 20 7b 5c 65 6d 20 | 68 65 61 64 5c 2f 7d 0a | a {\em |head\/}.|
|000050f0| 24 78 24 20 61 6e 64 20 | 61 20 7b 5c 65 6d 20 74 |$x$ and |a {\em t|
|00005100| 61 69 6c 5c 2f 7d 20 24 | 78 73 24 20 28 69 6e 20 |ail\/} $|xs$ (in |
|00005110| 77 68 69 63 68 20 63 61 | 73 65 20 69 74 27 73 20 |which ca|se it's |
|00005120| 77 72 69 74 74 65 6e 20 | 24 78 3a 78 73 24 29 2e |written |$x:xs$).|
|00005130| 0a 46 6f 72 20 65 78 61 | 6d 70 6c 65 2c 20 24 31 |.For exa|mple, $1|
|00005140| 3a 32 3a 33 3a 5c 6e 69 | 6c 24 20 69 73 20 24 5b |:2:3:\ni|l$ is $[|
|00005150| 31 2c 32 2c 33 5d 24 2e | 20 20 0a 0a 49 6e 20 61 |1,2,3]$.| ..In a|
|00005160| 20 73 69 6d 69 6c 61 72 | 20 66 61 73 68 69 6f 6e | similar| fashion|
|00005170| 20 74 6f 20 74 68 65 20 | 69 6d 70 6c 65 6d 65 6e | to the |implemen|
|00005180| 74 61 74 69 6f 6e 20 6f | 66 20 62 6f 6f 6c 65 61 |tation o|f boolea|
|00005190| 6e 73 2c 0a 61 20 6c 69 | 73 74 20 24 78 73 24 20 |ns,.a li|st $xs$ |
|000051a0| 69 73 20 69 6d 70 6c 65 | 6d 65 6e 74 65 64 20 61 |is imple|mented a|
|000051b0| 73 20 61 20 66 75 6e 63 | 74 69 6f 6e 20 6f 66 20 |s a func|tion of |
|000051c0| 74 68 65 20 66 6f 72 6d | 0a 5c 62 65 67 69 6e 7b |the form|.\begin{|
|000051d0| 65 71 6e 61 72 72 61 79 | 2a 7d 0a 20 20 20 78 73 |eqnarray|*}. xs|
|000051e0| 7e 66 7e 65 20 20 26 0a | 20 20 20 3d 20 20 26 0a |~f~e &.| = &.|
|000051f0| 20 20 20 5c 6c 65 66 74 | 5c 7b 0a 20 20 20 20 20 | \left|\{. |
|00005200| 20 5c 62 65 67 69 6e 7b | 61 72 72 61 79 7d 7b 6c | \begin{|array}{l|
|00005210| 6c 7d 0a 20 20 20 20 20 | 20 20 20 20 65 20 20 20 |l}. | e |
|00005220| 20 20 20 20 26 20 20 5c | 6d 62 6f 78 7b 69 66 20 | & \|mbox{if |
|00005230| 24 78 73 24 20 69 73 20 | 65 6d 70 74 79 7d 20 20 |$xs$ is |empty} |
|00005240| 5c 5c 0a 20 20 20 20 20 | 20 20 20 20 66 7e 79 7e |\\. | f~y~|
|00005250| 79 73 20 20 26 20 20 5c | 6d 62 6f 78 7b 69 66 20 |ys & \|mbox{if |
|00005260| 24 78 73 24 20 68 61 73 | 20 68 65 61 64 20 24 79 |$xs$ has| head $y|
|00005270| 24 20 61 6e 64 20 74 61 | 69 6c 20 24 79 73 24 7d |$ and ta|il $ys$}|
|00005280| 0a 20 20 20 20 20 20 5c | 65 6e 64 7b 61 72 72 61 |. \|end{arra|
|00005290| 79 7d 0a 20 20 20 5c 72 | 69 67 68 74 2e 0a 5c 65 |y}. \r|ight..\e|
|000052a0| 6e 64 7b 65 71 6e 61 72 | 72 61 79 2a 7d 0a 41 67 |nd{eqnar|ray*}.Ag|
|000052b0| 61 69 6e 2c 20 77 65 20 | 61 72 65 20 69 6d 70 6c |ain, we |are impl|
|000052c0| 65 6d 65 6e 74 69 6e 67 | 20 61 20 64 61 74 61 74 |ementing| a datat|
|000052d0| 79 70 65 20 61 73 20 61 | 20 66 75 6e 63 74 69 6f |ype as a| functio|
|000052e0| 6e 2c 20 61 20 71 75 69 | 74 65 20 70 6f 77 65 72 |n, a qui|te power|
|000052f0| 66 75 6c 0a 74 72 69 63 | 6b 2c 20 6a 75 73 74 20 |ful.tric|k, just |
|00005300| 6e 6f 74 20 6f 6e 65 20 | 75 73 75 61 6c 6c 79 20 |not one |usually |
|00005310| 73 65 65 6e 20 69 6e 20 | 5c 54 65 58 2e 20 20 57 |seen in |\TeX. W|
|00005320| 65 20 77 69 6c 6c 20 61 | 73 73 75 6d 65 20 74 68 |e will a|ssume th|
|00005330| 61 74 0a 77 68 65 6e 65 | 76 65 72 20 61 20 6c 69 |at.whene|ver a li|
|00005340| 73 74 20 24 78 3a 78 73 | 24 20 69 73 20 61 70 70 |st $x:xs|$ is app|
|00005350| 6c 69 65 64 20 74 6f 20 | 24 66 24 20 61 6e 64 20 |lied to |$f$ and |
|00005360| 24 65 24 2c 20 24 66 7e | 78 24 20 72 65 73 70 65 |$e$, $f~|x$ respe|
|00005370| 63 74 73 20 65 71 75 61 | 6c 69 74 79 2e 0a 54 68 |cts equa|lity..Th|
|00005380| 69 73 20 61 6c 6c 6f 77 | 73 20 75 73 20 74 6f 20 |is allow|s us to |
|00005390| 61 73 73 75 6d 65 20 74 | 68 61 74 20 69 66 20 24 |assume t|hat if $|
|000053a0| 78 73 20 3d 20 79 73 24 | 20 74 68 65 6e 20 24 78 |xs = ys$| then $x|
|000053b0| 3a 78 73 20 3d 20 78 3a | 79 73 24 2c 0a 77 68 69 |:xs = x:|ys$,.whi|
|000053c0| 63 68 20 69 73 20 68 61 | 6e 64 79 2e 20 20 0a 0a |ch is ha|ndy. ..|
|000053d0| 5c 73 75 62 73 65 63 74 | 69 6f 6e 7b 4e 69 6c 2c |\subsect|ion{Nil,|
|000053e0| 20 43 6f 6e 73 2c 20 53 | 74 72 65 61 6d 20 61 6e | Cons, S|tream an|
|000053f0| 64 20 53 69 6e 67 6c 65 | 74 6f 6e 7d 0a 0a 54 68 |d Single|ton}..Th|
|00005400| 65 20 73 69 6d 70 6c 65 | 73 74 20 6c 69 73 74 20 |e simple|st list |
|00005410| 69 73 20 24 4e 69 6c 24 | 2c 20 74 68 65 20 65 6d |is $Nil$|, the em|
|00005420| 70 74 79 20 6c 69 73 74 | 20 77 68 69 63 68 20 77 |pty list| which w|
|00005430| 65 20 68 61 76 65 20 62 | 65 65 6e 20 77 72 69 74 |e have b|een writ|
|00005440| 69 6e 67 0a 24 5c 6e 69 | 6c 24 2e 20 20 0a 5c 62 |ing.$\ni|l$. .\b|
|00005450| 65 67 69 6e 7b 65 71 6e | 61 72 72 61 79 2a 7d 0a |egin{eqn|array*}.|
|00005460| 20 20 20 4e 69 6c 20 20 | 26 20 20 3d 20 20 26 20 | Nil |& = & |
|00005470| 20 53 65 63 6f 6e 64 0a | 5c 65 6e 64 7b 65 71 6e | Second.|\end{eqn|
|00005480| 61 72 72 61 79 2a 7d 0a | 54 68 65 20 6f 74 68 65 |array*}.|The othe|
|00005490| 72 20 70 6f 73 73 69 62 | 6c 65 20 6c 69 73 74 20 |r possib|le list |
|000054a0| 69 73 20 24 43 6f 6e 73 | 7e 78 7e 78 73 24 2c 20 |is $Cons|~x~xs$, |
|000054b0| 77 68 69 63 68 20 68 61 | 73 20 68 65 61 64 20 24 |which ha|s head $|
|000054c0| 78 24 20 61 6e 64 20 74 | 61 69 6c 20 24 78 73 24 |x$ and t|ail $xs$|
|000054d0| 2e 0a 5c 62 65 67 69 6e | 7b 65 71 6e 61 72 72 61 |..\begin|{eqnarra|
|000054e0| 79 2a 7d 0a 20 20 20 43 | 6f 6e 73 7e 78 7e 78 73 |y*}. C|ons~x~xs|
|000054f0| 7e 66 7e 65 20 20 26 20 | 20 3d 20 20 26 20 20 66 |~f~e & | = & f|
|00005500| 7e 78 7e 78 73 0a 5c 65 | 6e 64 7b 65 71 6e 61 72 |~x~xs.\e|nd{eqnar|
|00005510| 72 61 79 2a 7d 0a 45 76 | 65 72 79 20 6c 69 73 74 |ray*}.Ev|ery list|
|00005520| 20 63 61 6e 20 62 65 20 | 63 6f 6e 73 74 72 75 63 | can be |construc|
|00005530| 74 65 64 20 75 73 69 6e | 67 20 74 68 65 73 65 20 |ted usin|g these |
|00005540| 66 75 6e 63 74 69 6f 6e | 73 2e 0a 54 68 65 20 6c |function|s..The l|
|00005550| 69 73 74 20 24 5b 31 2c | 32 2c 33 5d 24 20 69 73 |ist $[1,|2,3]$ is|
|00005560| 20 24 43 6f 6e 73 7e 31 | 7e 28 43 6f 6e 73 7e 32 | $Cons~1|~(Cons~2|
|00005570| 7e 28 43 6f 6e 73 7e 33 | 7e 4e 69 6c 29 29 24 2c |~(Cons~3|~Nil))$,|
|00005580| 20 61 6e 64 20 74 68 65 | 0a 6c 69 73 74 20 24 5b | and the|.list $[|
|00005590| 61 2c 61 2c 61 2c 5c 6c | 64 6f 74 73 5d 24 20 69 |a,a,a,\l|dots]$ i|
|000055a0| 73 20 24 53 74 72 65 61 | 6d 7e 61 24 20 77 68 65 |s $Strea|m~a$ whe|
|000055b0| 72 65 20 24 53 74 72 65 | 61 6d 24 20 69 73 20 64 |re $Stre|am$ is d|
|000055c0| 65 66 69 6e 65 64 3a 0a | 5c 62 65 67 69 6e 7b 65 |efined:.|\begin{e|
|000055d0| 71 6e 61 72 72 61 79 2a | 7d 0a 20 20 20 53 74 72 |qnarray*|}. Str|
|000055e0| 65 61 6d 7e 61 20 20 26 | 20 20 3d 20 20 26 20 20 |eam~a &| = & |
|000055f0| 43 6f 6e 73 7e 61 7e 28 | 53 74 72 65 61 6d 7e 61 |Cons~a~(|Stream~a|
|00005600| 29 0a 5c 65 6e 64 7b 65 | 71 6e 61 72 72 61 79 2a |).\end{e|qnarray*|
|00005610| 7d 0a 54 68 65 72 65 27 | 73 20 65 76 65 6e 20 61 |}.There'|s even a|
|00005620| 74 20 6c 65 61 73 74 20 | 6f 6e 65 20 61 70 70 6c |t least |one appl|
|00005630| 69 63 61 74 69 6f 6e 20 | 66 6f 72 20 69 6e 66 69 |ication |for infi|
|00005640| 6e 69 74 65 20 6c 69 73 | 74 73 2c 0a 61 73 20 77 |nite lis|ts,.as w|
|00005650| 65 27 6c 6c 20 73 65 65 | 20 69 6e 20 53 65 63 74 |e'll see| in Sect|
|00005660| 69 6f 6e 7e 5c 72 65 66 | 7b 6f 75 74 70 75 74 72 |ion~\ref|{outputr|
|00005670| 6f 75 74 69 6e 65 73 7d | 2e 0a 0a 54 68 65 20 73 |outines}|...The s|
|00005680| 69 6e 67 6c 65 74 6f 6e | 20 6c 69 73 74 20 24 5b |ingleton| list $[|
|00005690| 61 5d 24 20 69 73 20 24 | 53 69 6e 67 6c 65 74 6f |a]$ is $|Singleto|
|000056a0| 6e 7e 61 24 2c 20 64 65 | 66 69 6e 65 64 20 61 73 |n~a$, de|fined as|
|000056b0| 3a 0a 5c 62 65 67 69 6e | 7b 65 71 6e 61 72 72 61 |:.\begin|{eqnarra|
|000056c0| 79 2a 7d 0a 20 20 20 53 | 69 6e 67 6c 65 74 6f 6e |y*}. S|ingleton|
|000056d0| 7e 61 20 20 26 20 20 3d | 20 20 26 20 20 43 6f 6e |~a & =| & Con|
|000056e0| 73 7e 61 7e 4e 69 6c 0a | 5c 65 6e 64 7b 65 71 6e |s~a~Nil.|\end{eqn|
|000056f0| 61 72 72 61 79 2a 7d 0a | 54 68 65 73 65 20 61 6c |array*}.|These al|
|00005700| 6c 20 68 61 76 65 20 73 | 74 72 61 69 67 68 74 66 |l have s|traightf|
|00005710| 6f 72 77 61 72 64 20 5c | 54 65 58 5c 20 64 65 66 |orward \|TeX\ def|
|00005720| 69 6e 69 74 69 6f 6e 73 | 2e 0a 5c 62 65 67 69 6e |initions|..\begin|
|00005730| 7b 54 65 58 63 6f 64 65 | 7d 0a 5c 6c 65 74 5c 4e |{TeXcode|}.\let\N|
|00005740| 69 6c 3d 5c 53 65 63 6f | 6e 64 0a 5c 64 65 66 5c |il=\Seco|nd.\def\|
|00005750| 43 6f 6e 73 23 31 23 32 | 23 33 23 34 7b 23 33 7b |Cons#1#2|#3#4{#3{|
|00005760| 23 31 7d 7b 23 32 7d 7d | 0a 5c 64 65 66 5c 53 74 |#1}{#2}}|.\def\St|
|00005770| 72 65 61 6d 23 31 7b 5c | 43 6f 6e 73 7b 23 31 7d |ream#1{\|Cons{#1}|
|00005780| 7b 5c 53 74 72 65 61 6d | 7b 23 31 7d 7d 7d 0a 5c |{\Stream|{#1}}}.\|
|00005790| 64 65 66 5c 53 69 6e 67 | 6c 65 74 6f 6e 23 31 7b |def\Sing|leton#1{|
|000057a0| 5c 43 6f 6e 73 7b 23 31 | 7d 5c 4e 69 6c 7d 0a 5c |\Cons{#1|}\Nil}.\|
|000057b0| 65 6e 64 7b 54 65 58 63 | 6f 64 65 7d 0a 0a 5c 73 |end{TeXc|ode}..\s|
|000057c0| 75 62 73 65 63 74 69 6f | 6e 7b 48 65 61 64 20 61 |ubsectio|n{Head a|
|000057d0| 6e 64 20 54 61 69 6c 7d | 0a 0a 53 6f 2c 20 77 65 |nd Tail}|..So, we|
|000057e0| 20 63 61 6e 20 63 6f 6e | 73 74 72 75 63 74 20 61 | can con|struct a|
|000057f0| 6e 79 20 6c 69 73 74 20 | 77 65 20 6c 69 6b 65 2c |ny list |we like,|
|00005800| 20 62 75 74 20 77 65 20 | 73 74 69 6c 6c 20 63 61 | but we |still ca|
|00005810| 6e 27 74 20 67 65 74 20 | 61 6e 79 20 69 6e 66 6f |n't get |any info|
|00005820| 72 6d 61 74 69 6f 6e 0a | 6f 75 74 20 6f 66 20 69 |rmation.|out of i|
|00005830| 74 2e 20 20 54 6f 20 62 | 65 67 69 6e 20 77 69 74 |t. To b|egin wit|
|00005840| 68 2c 20 77 65 27 64 20 | 6c 69 6b 65 20 74 6f 20 |h, we'd |like to |
|00005850| 62 65 20 61 62 6c 65 20 | 74 6f 20 67 65 74 20 74 |be able |to get t|
|00005860| 68 65 20 68 65 61 64 0a | 61 6e 64 20 74 61 69 6c |he head.|and tail|
|00005870| 20 6f 66 20 61 20 6c 69 | 73 74 2e 0a 5c 62 65 67 | of a li|st..\beg|
|00005880| 69 6e 7b 65 71 6e 61 72 | 72 61 79 2a 7d 0a 20 20 |in{eqnar|ray*}. |
|00005890| 20 48 65 61 64 7e 78 73 | 20 20 26 20 20 3d 20 20 | Head~xs| & = |
|000058a0| 26 20 20 78 73 7e 46 69 | 72 73 74 7e 45 72 72 6f |& xs~Fi|rst~Erro|
|000058b0| 72 20 20 5c 5c 0a 20 20 | 20 54 61 69 6c 7e 78 73 |r \\. | Tail~xs|
|000058c0| 20 20 26 20 20 3d 20 20 | 26 20 20 78 73 7e 53 65 | & = |& xs~Se|
|000058d0| 63 6f 6e 64 7e 45 72 72 | 6f 72 0a 5c 65 6e 64 7b |cond~Err|or.\end{|
|000058e0| 65 71 6e 61 72 72 61 79 | 2a 7d 0a 46 6f 72 20 65 |eqnarray|*}.For e|
|000058f0| 78 61 6d 70 6c 65 2c 20 | 74 68 65 20 74 61 69 6c |xample, |the tail|
|00005900| 20 6f 66 20 24 78 3a 78 | 73 24 20 69 73 0a 5c 62 | of $x:x|s$ is.\b|
|00005910| 65 67 69 6e 7b 65 71 6e | 61 72 72 61 79 2a 7d 0a |egin{eqn|array*}.|
|00005920| 20 20 20 5c 73 74 61 72 | 74 7b 54 61 69 6c 7e 28 | \star|t{Tail~(|
|00005930| 43 6f 6e 73 7e 78 7e 78 | 73 29 7d 20 20 0a 20 20 |Cons~x~x|s)} . |
|00005940| 20 26 20 20 3d 20 20 26 | 20 20 43 6f 6e 73 7e 78 | & = &| Cons~x|
|00005950| 7e 78 73 7e 53 65 63 6f | 6e 64 7e 45 72 72 6f 72 |~xs~Seco|nd~Error|
|00005960| 20 20 5c 5c 0a 20 20 20 | 26 20 20 3d 20 20 26 20 | \\. |& = & |
|00005970| 20 53 65 63 6f 6e 64 7e | 78 7e 78 73 20 20 5c 5c | Second~|x~xs \\|
|00005980| 0a 20 20 20 26 20 20 3d | 20 20 26 20 20 5c 54 61 |. & =| & \Ta|
|00005990| 69 6c 7b 5c 43 6f 6e 73 | 7b 78 7d 7b 78 73 7d 7d |il{\Cons|{x}{xs}}|
|000059a0| 0a 5c 65 6e 64 7b 65 71 | 6e 61 72 72 61 79 2a 7d |.\end{eq|narray*}|
|000059b0| 0a 54 68 65 20 74 61 69 | 6c 20 6f 66 20 24 5c 6e |.The tai|l of $\n|
|000059c0| 69 6c 24 20 69 73 2c 20 | 61 73 20 6f 6e 65 20 77 |il$ is, |as one w|
|000059d0| 6f 75 6c 64 20 65 78 70 | 65 63 74 2c 0a 5c 62 65 |ould exp|ect,.\be|
|000059e0| 67 69 6e 7b 65 71 6e 61 | 72 72 61 79 2a 7d 0a 20 |gin{eqna|rray*}. |
|000059f0| 20 20 5c 73 74 61 72 74 | 7b 54 61 69 6c 7e 4e 69 | \start|{Tail~Ni|
|00005a00| 6c 7d 20 20 0a 20 20 20 | 26 20 20 3d 20 20 26 20 |l} . |& = & |
|00005a10| 20 4e 69 6c 7e 53 65 63 | 6f 6e 64 7e 45 72 72 6f | Nil~Sec|ond~Erro|
|00005a20| 72 20 20 5c 5c 0a 20 20 | 20 26 20 20 3d 20 20 26 |r \\. | & = &|
|00005a30| 20 20 45 72 72 6f 72 0a | 5c 65 6e 64 7b 65 71 6e | Error.|\end{eqn|
|00005a40| 61 72 72 61 79 2a 7d 0a | 41 6e 64 20 74 68 65 20 |array*}.|And the |
|00005a50| 68 65 61 64 20 6f 66 20 | 24 53 74 72 65 61 6d 7e |head of |$Stream~|
|00005a60| 61 24 20 69 73 0a 5c 62 | 65 67 69 6e 7b 65 71 6e |a$ is.\b|egin{eqn|
|00005a70| 61 72 72 61 79 2a 7d 0a | 20 20 20 5c 73 74 61 72 |array*}.| \star|
|00005a80| 74 7b 48 65 61 64 7e 28 | 53 74 72 65 61 6d 7e 61 |t{Head~(|Stream~a|
|00005a90| 29 7d 20 20 0a 20 20 20 | 26 20 20 3d 20 20 26 20 |)} . |& = & |
|00005aa0| 20 53 74 72 65 61 6d 7e | 61 7e 46 69 72 73 74 7e | Stream~|a~First~|
|00005ab0| 45 72 72 6f 72 20 20 5c | 5c 0a 20 20 20 26 20 20 |Error \|\. & |
|00005ac0| 3d 20 20 26 20 20 43 6f | 6e 73 7e 61 7e 28 53 74 |= & Co|ns~a~(St|
|00005ad0| 72 65 61 6d 7e 61 29 7e | 46 69 72 73 74 7e 45 72 |ream~a)~|First~Er|
|00005ae0| 72 6f 72 20 20 5c 5c 0a | 20 20 20 26 20 20 3d 20 |ror \\.| & = |
|00005af0| 20 26 20 20 46 69 72 73 | 74 7e 61 7e 28 53 74 72 | & Firs|t~a~(Str|
|00005b00| 65 61 6d 7e 61 29 20 20 | 5c 5c 0a 20 20 20 26 20 |eam~a) |\\. & |
|00005b10| 20 3d 20 20 26 20 20 5c | 48 65 61 64 7b 5c 53 74 | = & \|Head{\St|
|00005b20| 72 65 61 6d 7b 61 7d 7d | 0a 5c 65 6e 64 7b 65 71 |ream{a}}|.\end{eq|
|00005b30| 6e 61 72 72 61 79 2a 7d | 0a 53 6f 20 77 65 20 63 |narray*}|.So we c|
|00005b40| 61 6e 20 67 65 74 20 74 | 68 65 20 68 65 61 64 20 |an get t|he head |
|00005b50| 6f 66 20 61 6e 20 69 6e | 66 69 6e 69 74 65 20 6c |of an in|finite l|
|00005b60| 69 73 74 20 69 6e 20 66 | 69 6e 69 74 65 20 74 69 |ist in f|inite ti|
|00005b70| 6d 65 2e 20 20 54 68 69 | 73 20 69 73 0a 66 6f 72 |me. Thi|s is.for|
|00005b80| 74 75 6e 61 74 65 2c 20 | 61 73 20 6f 74 68 65 72 |tunate, |as other|
|00005b90| 77 69 73 65 20 74 68 65 | 72 65 20 77 6f 75 6c 64 |wise the|re would|
|00005ba0| 6e 27 74 20 62 65 20 6d | 75 63 68 20 70 6f 69 6e |n't be m|uch poin|
|00005bb0| 74 20 69 6e 20 61 6c 6c | 6f 77 69 6e 67 0a 69 6e |t in all|owing.in|
|00005bc0| 66 69 6e 69 74 65 20 6f | 62 6a 65 63 74 73 2e 20 |finite o|bjects. |
|00005bd0| 0a 5c 62 65 67 69 6e 7b | 54 65 58 63 6f 64 65 7d |.\begin{|TeXcode}|
|00005be0| 0a 5c 64 65 66 5c 48 65 | 61 64 23 31 7b 23 31 5c |.\def\He|ad#1{#1\|
|00005bf0| 46 69 72 73 74 5c 45 72 | 72 6f 72 7d 0a 5c 64 65 |First\Er|ror}.\de|
|00005c00| 66 5c 54 61 69 6c 23 31 | 7b 23 31 5c 53 65 63 6f |f\Tail#1|{#1\Seco|
|00005c10| 6e 64 5c 45 72 72 6f 72 | 7d 0a 5c 65 6e 64 7b 54 |nd\Error|}.\end{T|
|00005c20| 65 58 63 6f 64 65 7d 0a | 0a 5c 73 75 62 73 65 63 |eXcode}.|.\subsec|
|00005c30| 74 69 6f 6e 7b 46 6f 6c | 64 6c 20 61 6e 64 20 46 |tion{Fol|dl and F|
|00005c40| 6f 6c 64 72 7d 0a 0a 55 | 73 69 6e 67 20 24 48 65 |oldr}..U|sing $He|
|00005c50| 61 64 24 20 61 6e 64 20 | 24 54 61 69 6c 24 20 77 |ad$ and |$Tail$ w|
|00005c60| 65 20 63 61 6e 20 67 65 | 74 20 61 74 20 74 68 65 |e can ge|t at the|
|00005c70| 20 62 65 67 69 6e 6e 69 | 6e 67 20 6f 66 20 61 6e | beginni|ng of an|
|00005c80| 79 20 6e 6f 6e 2d 65 6d | 70 74 79 20 6c 69 73 74 |y non-em|pty list|
|00005c90| 2c 0a 62 75 74 20 69 6e | 20 67 65 6e 65 72 61 6c |,.but in| general|
|00005ca0| 20 77 65 20 6e 65 65 64 | 20 6d 6f 72 65 20 69 6e | we need| more in|
|00005cb0| 66 6f 72 6d 61 74 69 6f | 6e 20 74 68 61 6e 20 74 |formatio|n than t|
|00005cc0| 68 61 74 2e 20 20 52 61 | 74 68 65 72 20 74 68 61 |hat. Ra|ther tha|
|00005cd0| 6e 20 77 72 69 74 65 0a | 61 20 77 68 6f 6c 65 20 |n write.|a whole |
|00005ce0| 62 75 6e 63 68 20 6f 66 | 20 72 65 63 75 72 73 69 |bunch of| recursi|
|00005cf0| 76 65 20 66 75 6e 63 74 | 69 6f 6e 73 20 6f 6e 20 |ve funct|ions on |
|00005d00| 6c 69 73 74 73 2c 20 49 | 27 6c 6c 20 69 6d 70 6c |lists, I|'ll impl|
|00005d10| 65 6d 65 6e 74 20 74 77 | 6f 0a 66 61 69 72 6c 79 |ement tw|o.fairly|
|00005d20| 20 67 65 6e 65 72 61 6c | 20 66 75 6e 63 74 69 6f | general| functio|
|00005d30| 6e 73 2c 20 77 69 74 68 | 20 77 68 69 63 68 20 77 |ns, with| which w|
|00005d40| 65 20 63 61 6e 20 69 6d | 70 6c 65 6d 65 6e 74 20 |e can im|plement |
|00005d50| 28 61 6c 6d 6f 73 74 29 | 20 65 76 65 72 79 74 68 |(almost)| everyth|
|00005d60| 69 6e 67 0a 65 6c 73 65 | 2e 0a 0a 24 46 6f 6c 64 |ing.else|...$Fold|
|00005d70| 6c 24 20 61 6e 64 20 24 | 46 6f 6c 64 72 24 20 62 |l$ and $|Foldr$ b|
|00005d80| 6f 74 68 20 74 61 6b 65 | 20 69 6e 20 66 75 6e 63 |oth take| in func|
|00005d90| 74 69 6f 6e 73 20 61 6e | 64 20 61 70 70 6c 79 20 |tions an|d apply |
|00005da0| 74 68 65 6d 20 72 65 63 | 75 72 73 69 76 65 6c 79 |them rec|ursively|
|00005db0| 0a 74 6f 20 61 20 6c 69 | 73 74 2e 20 20 24 46 6f |.to a li|st. $Fo|
|00005dc0| 6c 64 6c 24 20 73 74 61 | 72 74 73 20 61 74 20 74 |ldl$ sta|rts at t|
|00005dd0| 68 65 20 6c 65 66 74 20 | 6f 66 20 74 68 65 20 6c |he left |of the l|
|00005de0| 69 73 74 2c 20 61 6e 64 | 20 24 46 6f 6c 64 72 24 |ist, and| $Foldr$|
|00005df0| 0a 73 74 61 72 74 73 20 | 61 74 20 74 68 65 20 72 |.starts |at the r|
|00005e00| 69 67 68 74 2e 20 20 46 | 6f 72 20 65 78 61 6d 70 |ight. F|or examp|
|00005e10| 6c 65 2c 0a 5c 62 65 67 | 69 6e 7b 65 71 6e 61 72 |le,.\beg|in{eqnar|
|00005e20| 72 61 79 2a 7d 0a 20 20 | 20 46 6f 6c 64 6c 7e 66 |ray*}. | Foldl~f|
|00005e30| 7e 65 7e 5b 31 2c 32 2c | 33 5d 20 20 26 20 20 3d |~e~[1,2,|3] & =|
|00005e40| 20 20 26 20 20 66 7e 28 | 66 7e 28 66 7e 65 7e 31 | & f~(|f~(f~e~1|
|00005e50| 29 7e 32 29 7e 33 20 20 | 5c 5c 0a 20 20 20 46 6f |)~2)~3 |\\. Fo|
|00005e60| 6c 64 72 7e 66 7e 65 7e | 5b 31 2c 32 2c 33 5d 20 |ldr~f~e~|[1,2,3] |
|00005e70| 20 26 20 20 3d 20 20 26 | 20 20 66 7e 31 7e 28 66 | & = &| f~1~(f|
|00005e80| 7e 32 7e 28 66 7e 33 7e | 65 29 29 0a 5c 65 6e 64 |~2~(f~3~|e)).\end|
|00005e90| 7b 65 71 6e 61 72 72 61 | 79 2a 7d 0a 54 68 65 73 |{eqnarra|y*}.Thes|
|00005ea0| 65 20 66 75 6e 63 74 69 | 6f 6e 73 20 77 69 6c 6c |e functi|ons will|
|00005eb0| 20 62 65 20 75 73 65 64 | 20 61 20 6c 6f 74 20 6c | be used| a lot l|
|00005ec0| 61 74 65 72 20 6f 6e 2e | 20 20 24 46 6f 6c 64 6c |ater on.| $Foldl|
|00005ed0| 24 20 63 61 6e 20 62 65 | 20 64 65 66 69 6e 65 64 |$ can be| defined|
|00005ee0| 3a 0a 5c 62 65 67 69 6e | 7b 65 71 6e 61 72 72 61 |:.\begin|{eqnarra|
|00005ef0| 79 2a 7d 0a 20 20 20 20 | 20 20 46 6f 6c 64 6c 7e |y*}. | Foldl~|
|00005f00| 66 7e 65 7e 78 73 20 20 | 26 20 20 3d 20 20 26 20 |f~e~xs |& = & |
|00005f10| 20 78 73 7e 28 46 6f 6c | 64 6c 27 7e 66 7e 65 29 | xs~(Fol|dl'~f~e)|
|00005f20| 7e 65 20 20 5c 5c 0a 20 | 20 20 46 6f 6c 64 6c 27 |~e \\. | Foldl'|
|00005f30| 7e 66 7e 65 7e 78 7e 78 | 73 20 20 26 20 20 3d 20 |~f~e~x~x|s & = |
|00005f40| 20 26 20 20 46 6f 6c 64 | 6c 7e 66 7e 28 66 7e 65 | & Fold|l~f~(f~e|
|00005f50| 7e 78 29 7e 78 73 0a 5c | 65 6e 64 7b 65 71 6e 61 |~x)~xs.\|end{eqna|
|00005f60| 72 72 61 79 2a 7d 0a 53 | 6f 20 24 46 6f 6c 64 6c |rray*}.S|o $Foldl|
|00005f70| 7e 66 7e 65 7e 5c 6e 69 | 6c 24 20 69 73 0a 5c 62 |~f~e~\ni|l$ is.\b|
|00005f80| 65 67 69 6e 7b 65 71 6e | 61 72 72 61 79 2a 7d 0a |egin{eqn|array*}.|
|00005f90| 20 20 20 5c 73 74 61 72 | 74 7b 46 6f 6c 64 6c 7e | \star|t{Foldl~|
|00005fa0| 66 7e 65 7e 4e 69 6c 7d | 20 20 0a 20 20 20 26 20 |f~e~Nil}| . & |
|00005fb0| 20 3d 20 20 26 20 20 4e | 69 6c 7e 28 46 6f 6c 64 | = & N|il~(Fold|
|00005fc0| 6c 27 7e 66 7e 65 29 7e | 65 20 20 5c 5c 0a 20 20 |l'~f~e)~|e \\. |
|00005fd0| 20 26 20 20 3d 20 20 26 | 20 20 5c 46 6f 6c 64 6c | & = &| \Foldl|
|00005fe0| 7b 66 7d 7b 65 7d 5c 4e | 69 6c 0a 5c 65 6e 64 7b |{f}{e}\N|il.\end{|
|00005ff0| 65 71 6e 61 72 72 61 79 | 2a 7d 0a 41 6e 64 20 24 |eqnarray|*}.And $|
|00006000| 46 6f 6c 64 6c 7e 66 7e | 65 7e 28 78 3a 78 73 29 |Foldl~f~|e~(x:xs)|
|00006010| 24 20 69 73 0a 5c 62 65 | 67 69 6e 7b 65 71 6e 61 |$ is.\be|gin{eqna|
|00006020| 72 72 61 79 2a 7d 0a 20 | 20 20 5c 73 74 61 72 74 |rray*}. | \start|
|00006030| 7b 46 6f 6c 64 6c 7e 66 | 7e 65 7e 28 43 6f 6e 73 |{Foldl~f|~e~(Cons|
|00006040| 7e 78 7e 78 73 29 7d 20 | 20 0a 20 20 20 26 20 20 |~x~xs)} | . & |
|00006050| 3d 20 20 26 20 20 43 6f | 6e 73 7e 78 7e 78 73 7e |= & Co|ns~x~xs~|
|00006060| 28 46 6f 6c 64 6c 27 7e | 66 7e 65 29 7e 65 20 20 |(Foldl'~|f~e)~e |
|00006070| 5c 5c 0a 20 20 20 26 20 | 20 3d 20 20 26 20 20 46 |\\. & | = & F|
|00006080| 6f 6c 64 6c 27 7e 66 7e | 65 7e 78 7e 78 73 20 20 |oldl'~f~|e~x~xs |
|00006090| 5c 5c 0a 20 20 20 26 20 | 20 3d 20 20 26 20 20 46 |\\. & | = & F|
|000060a0| 6f 6c 64 6c 7e 66 7e 28 | 66 7e 65 7e 78 29 7e 78 |oldl~f~(|f~e~x)~x|
|000060b0| 73 0a 5c 65 6e 64 7b 65 | 71 6e 61 72 72 61 79 2a |s.\end{e|qnarray*|
|000060c0| 7d 0a 46 6f 72 20 65 78 | 61 6d 70 6c 65 2c 20 24 |}.For ex|ample, $|
|000060d0| 46 6f 6c 64 6c 7e 66 7e | 65 7e 5b 31 2c 32 2c 33 |Foldl~f~|e~[1,2,3|
|000060e0| 5d 24 20 69 73 0a 5c 62 | 65 67 69 6e 7b 65 71 6e |]$ is.\b|egin{eqn|
|000060f0| 61 72 72 61 79 2a 7d 0a | 20 20 20 5c 73 74 61 72 |array*}.| \star|
|00006100| 74 7b 46 6f 6c 64 6c 7e | 66 7e 65 7e 5b 31 2c 32 |t{Foldl~|f~e~[1,2|
|00006110| 2c 33 5d 7d 20 20 0a 20 | 20 20 26 20 20 3d 20 20 |,3]} . | & = |
|00006120| 26 20 20 46 6f 6c 64 6c | 7e 66 7e 28 66 7e 65 7e |& Foldl|~f~(f~e~|
|00006130| 31 29 7e 5b 32 2c 33 5d | 20 20 5c 5c 0a 20 20 20 |1)~[2,3]| \\. |
|00006140| 26 20 20 3d 20 20 26 20 | 20 46 6f 6c 64 6c 7e 66 |& = & | Foldl~f|
|00006150| 7e 28 66 7e 28 66 7e 65 | 7e 31 29 7e 32 29 7e 5b |~(f~(f~e|~1)~2)~[|
|00006160| 33 5d 20 20 5c 5c 0a 20 | 20 20 26 20 20 3d 20 20 |3] \\. | & = |
|00006170| 26 20 20 46 6f 6c 64 6c | 7e 66 7e 28 66 7e 28 66 |& Foldl|~f~(f~(f|
|00006180| 7e 28 66 7e 65 7e 31 29 | 7e 32 29 7e 33 29 7e 5c |~(f~e~1)|~2)~3)~\|
|00006190| 6e 69 6c 20 20 5c 5c 0a | 20 20 20 26 20 20 3d 20 |nil \\.| & = |
|000061a0| 20 26 20 20 66 7e 28 66 | 7e 28 66 7e 65 7e 31 29 | & f~(f|~(f~e~1)|
|000061b0| 7e 32 29 7e 33 0a 5c 65 | 6e 64 7b 65 71 6e 61 72 |~2)~3.\e|nd{eqnar|
|000061c0| 72 61 79 2a 7d 0a 61 73 | 20 70 72 6f 6d 69 73 65 |ray*}.as| promise|
|000061d0| 64 2e 20 20 53 69 6d 69 | 6c 61 72 6c 79 2c 20 77 |d. Simi|larly, w|
|000061e0| 65 20 63 61 6e 20 64 65 | 66 69 6e 65 20 24 46 6f |e can de|fine $Fo|
|000061f0| 6c 64 72 24 20 61 73 0a | 5c 62 65 67 69 6e 7b 65 |ldr$ as.|\begin{e|
|00006200| 71 6e 61 72 72 61 79 2a | 7d 0a 20 20 20 20 20 20 |qnarray*|}. |
|00006210| 46 6f 6c 64 72 7e 66 7e | 65 7e 78 73 20 20 26 20 |Foldr~f~|e~xs & |
|00006220| 20 3d 20 20 26 20 20 78 | 73 7e 28 46 6f 6c 64 72 | = & x|s~(Foldr|
|00006230| 27 7e 66 7e 65 29 7e 65 | 20 20 5c 5c 0a 20 20 20 |'~f~e)~e| \\. |
|00006240| 46 6f 6c 64 72 27 7e 66 | 7e 65 7e 78 7e 78 73 20 |Foldr'~f|~e~x~xs |
|00006250| 20 26 20 20 3d 20 20 26 | 20 20 66 7e 78 7e 28 46 | & = &| f~x~(F|
|00006260| 6f 6c 64 72 7e 66 7e 65 | 7e 78 73 29 0a 5c 65 6e |oldr~f~e|~xs).\en|
|00006270| 64 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 46 6f 72 |d{eqnarr|ay*}.For|
|00006280| 20 24 46 6f 6c 64 72 7e | 66 24 20 74 6f 20 72 65 | $Foldr~|f$ to re|
|00006290| 73 70 65 63 74 20 65 71 | 75 61 6c 69 74 79 2c 20 |spect eq|uality, |
|000062a0| 24 66 7e 78 24 20 73 68 | 6f 75 6c 64 20 72 65 73 |$f~x$ sh|ould res|
|000062b0| 70 65 63 74 20 65 71 75 | 61 6c 69 74 79 2e 0a 0a |pect equ|ality...|
|000062c0| 57 68 65 6e 20 77 65 20 | 64 6f 20 74 68 65 20 75 |When we |do the u|
|000062d0| 6e 66 6f 6c 64 69 6e 67 | 2c 20 77 65 20 64 69 73 |nfolding|, we dis|
|000062e0| 63 6f 76 65 72 20 74 68 | 61 74 0a 5c 62 65 67 69 |cover th|at.\begi|
|000062f0| 6e 7b 65 71 6e 61 72 72 | 61 79 2a 7d 0a 20 20 20 |n{eqnarr|ay*}. |
|00006300| 20 20 20 20 46 6f 6c 64 | 72 7e 66 7e 65 7e 5c 6e | Fold|r~f~e~\n|
|00006310| 69 6c 20 20 26 20 20 3d | 20 20 26 20 20 65 20 20 |il & =| & e |
|00006320| 5c 5c 0a 20 20 20 46 6f | 6c 64 72 7e 66 7e 65 7e |\\. Fo|ldr~f~e~|
|00006330| 28 78 3a 78 73 29 20 20 | 26 20 20 3d 20 20 26 20 |(x:xs) |& = & |
|00006340| 20 66 7e 65 7e 28 46 6f | 6c 64 72 7e 66 7e 65 7e | f~e~(Fo|ldr~f~e~|
|00006350| 78 73 29 0a 5c 65 6e 64 | 7b 65 71 6e 61 72 72 61 |xs).\end|{eqnarra|
|00006360| 79 2a 7d 0a 24 46 6f 6c | 64 72 24 20 74 65 6e 64 |y*}.$Fol|dr$ tend|
|00006370| 73 20 74 6f 20 62 65 20 | 6d 6f 72 65 20 65 66 66 |s to be |more eff|
|00006380| 69 63 69 65 6e 74 20 74 | 68 61 6e 20 24 46 6f 6c |icient t|han $Fol|
|00006390| 64 6c 24 2c 20 62 65 63 | 61 75 73 65 20 24 46 6f |dl$, bec|ause $Fo|
|000063a0| 6c 64 6c 24 0a 68 61 73 | 20 74 6f 20 72 75 6e 20 |ldl$.has| to run |
|000063b0| 61 6c 6f 6e 67 20 74 68 | 65 20 65 6e 74 69 72 65 |along th|e entire|
|000063c0| 20 6c 69 73 74 20 62 65 | 66 6f 72 65 20 69 74 20 | list be|fore it |
|000063d0| 63 61 6e 20 73 74 61 72 | 74 20 61 70 70 6c 79 69 |can star|t applyi|
|000063e0| 6e 67 20 24 66 24 2c 0a | 77 68 65 72 65 61 73 20 |ng $f$,.|whereas |
|000063f0| 24 46 6f 6c 64 72 24 20 | 63 61 6e 20 61 70 70 6c |$Foldr$ |can appl|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.